Example usage for java.util EnumSet noneOf

List of usage examples for java.util EnumSet noneOf

Introduction

In this page you can find the example usage for java.util EnumSet noneOf.

Prototype

public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType) 

Source Link

Document

Creates an empty enum set with the specified element type.

Usage

From source file:org.apache.sentry.policy.solr.TestSolrAuthorizationProviderGeneralCases.java

@Test
public void testAnalyst() throws Exception {
    Set<SolrModelAction> updateOnly = EnumSet.of(SolrModelAction.UPDATE);
    doTestAuthProviderOnCollection(SUB_ANALYST, COLL_PURCHASES, updateOnly);

    Set<SolrModelAction> allActions = EnumSet.allOf(SolrModelAction.class);
    doTestAuthProviderOnCollection(SUB_ANALYST, COLL_ANALYST1, allActions);
    doTestAuthProviderOnCollection(SUB_ANALYST, COLL_JRANALYST1, allActions);

    Set<SolrModelAction> queryUpdateOnly = EnumSet.of(QUERY, UPDATE);
    doTestAuthProviderOnCollection(SUB_ANALYST, COLL_TMP, queryUpdateOnly);

    Set<SolrModelAction> noActions = EnumSet.noneOf(SolrModelAction.class);
    doTestAuthProviderOnCollection(SUB_ANALYST, COLL_PURCHASES_PARTIAL, noActions);
}

From source file:net.sourceforge.pmd.lang.java.rule.codestyle.UnnecessaryModifierRule.java

@Override
public Object visit(final ASTMethodDeclaration node, Object data) {
    Set<Modifier> unnecessary = EnumSet.noneOf(Modifier.class);

    if (node.isSyntacticallyPublic()) {
        unnecessary.add(Modifier.PUBLIC);
    }//  w w w  . jav a 2s  .  co m
    if (node.isSyntacticallyAbstract()) {
        unnecessary.add(Modifier.ABSTRACT);
    }

    checkDeclarationInInterfaceType(data, node, unnecessary);

    if (node.isFinal()) {
        // If the method is annotated by @SafeVarargs then it's ok
        if (!isSafeVarargs(node)) {
            if (node.isPrivate()) {
                reportUnnecessaryModifiers(data, node, Modifier.FINAL, "private methods cannot be overridden");
            } else {
                final Node n = node.getNthParent(3);
                // A final method of an anonymous class / enum constant. Neither can be extended / overridden
                if (n instanceof ASTAllocationExpression || n instanceof ASTEnumConstant) {
                    reportUnnecessaryModifiers(data, node, Modifier.FINAL,
                            "an anonymous class cannot be extended");
                } else if (n instanceof ASTClassOrInterfaceDeclaration && ((AccessNode) n).isFinal()) {
                    reportUnnecessaryModifiers(data, node, Modifier.FINAL,
                            "the method is already in a final class");
                }
            }
        }
    }

    return data;
}

From source file:com.netflix.genie.web.controllers.CommandRestController.java

/**
 * Get Command configuration based on user parameters.
 *
 * @param name      Name for command (optional)
 * @param user      The user who created the configuration (optional)
 * @param statuses  The statuses of the commands to get (optional)
 * @param tags      The set of tags you want the command for.
 * @param page      The page to get// w w w.  j av a2  s .com
 * @param assembler The paged resources assembler to use
 * @return All the Commands matching the criteria or all if no criteria
 * @throws GenieException For any error
 */
@GetMapping(produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public PagedResources<CommandResource> getCommands(
        @RequestParam(value = "name", required = false) final String name,
        @RequestParam(value = "user", required = false) final String user,
        @RequestParam(value = "status", required = false) final Set<String> statuses,
        @RequestParam(value = "tag", required = false) final Set<String> tags,
        @PageableDefault(size = 64, sort = { "updated" }, direction = Sort.Direction.DESC) final Pageable page,
        final PagedResourcesAssembler<Command> assembler) throws GenieException {
    log.debug("Called [name | user | status | tags | page]");
    log.debug("{} | {} | {} | {} | {}", name, user, statuses, tags, page);

    Set<CommandStatus> enumStatuses = null;
    if (statuses != null) {
        enumStatuses = EnumSet.noneOf(CommandStatus.class);
        for (final String status : statuses) {
            enumStatuses.add(CommandStatus.parse(status));
        }
    }

    // Build the self link which will be used for the next, previous, etc links
    final Link self = ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(CommandRestController.class)
            .getCommands(name, user, statuses, tags, page, assembler)).withSelfRel();

    return assembler.toResource(this.commandService.getCommands(name, user, enumStatuses, tags, page),
            this.commandResourceAssembler, self);
}

From source file:org.springframework.cloud.dataflow.server.stream.AppDeployerStreamDeployer.java

@Override
public DeploymentState streamState(String streamName) {
    Set<DeploymentState> appStates = EnumSet.noneOf(DeploymentState.class);
    StreamDefinition stream = this.streamDefinitionRepository.findOne(streamName);
    for (StreamAppDefinition appDefinition : stream.getAppDefinitions()) {
        String key = DeploymentKey.forStreamAppDefinition(appDefinition);
        String id = this.deploymentIdRepository.findOne(key);
        if (id != null) {
            AppStatus status = this.appDeployer.status(id);
            appStates.add(status.getState());
        } else {/*  w  w w  . j av a  2  s  . c  o m*/
            appStates.add(DeploymentState.undeployed);
        }
    }
    return StreamDeployerUtil.aggregateState(appStates);
}

From source file:org.photovault.swingui.JAIPhotoViewer.java

/**
 Finds the best instance of the current photo and shows it. The instance is 
 selected so that it needs as little postprocessing as possible. Hovewer, the 
 operations in {@link dynOps} must not be preapplied in the instance since 
 these may be changing during viewing of the image.
         //from w ww  .ja  v a  2  s .c  o m
 */
private void showBestInstance() throws PhotovaultException {
    EnumSet<ImageOperations> allowedOps = EnumSet.allOf(ImageOperations.class);
    allowedOps.removeAll(dynOps);
    int w = imageView.getWidth();
    int h = imageView.getHeight();
    Dimension croppedSize = photo.getCroppedSize();
    double ar = croppedSize.getWidth() / croppedSize.getHeight();
    if (w > ar * h) {
        w = (int) (h * ar);
    } else {
        h = (int) (w / ar);
    }
    ImageDescriptorBase image = photo.getPreferredImage(EnumSet.noneOf(ImageOperations.class), allowedOps, w, h,
            Integer.MAX_VALUE, Integer.MAX_VALUE);
    if (image != null && image.getLocator().equals("image#0")) {
        File imageFile = image.getFile().findAvailableCopy();
        if (imageFile != null && imageFile.canRead()) {
            // TODO: is this really needed?
            String fname = imageFile.getName();
            int lastDotPos = fname.lastIndexOf(".");
            if (lastDotPos <= 0 || lastDotPos >= fname.length() - 1) {
                // TODO: error handling needs thinking!!!!
                // throw new IOException( "Cannot determine file type extension of " + imageFile.getAbsolutePath() );
                fireViewChangeEvent();
                return;
            }
            PhotovaultImageFactory imageFactory = new PhotovaultImageFactory();
            PhotovaultImage img = null;
            try {
                /*
                 Do not read the image yet since setting raw conversion
                 parameters later may force a re-read.
                 */
                img = imageFactory.create(imageFile, false, false);
            } catch (PhotovaultException ex) {
                final JAIPhotoViewer component = this;
                final String msg = ex.getMessage();
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(component, msg, "Error loading file",
                                JOptionPane.ERROR_MESSAGE);
                    }
                });
            }
            if (img != null) {
                appliedOps = EnumSet.noneOf(ImageOperations.class);
                if (rawImage != null) {
                    rawImage.removeChangeListener(this);
                }
                if (img instanceof RawImage) {
                    rawImage = (RawImage) img;
                    rawImage.setRawSettings(
                            localRawSettings != null ? localRawSettings : photo.getRawSettings());
                    rawImage.addChangeListener(this);
                    // Check the correct resolution for this image
                    if (isFit) {
                        fit();
                    } else {
                        setScale(getScale());
                    }
                } else {
                    rawImage = null;
                    rawConvScaling = 1.0f;
                }
            }
            if (image instanceof CopyImageDescriptor) {
                // This is a copy, so it may be cropped already
                appliedOps = ((CopyImageDescriptor) image).getAppliedOperations();
                if (!appliedOps.contains(ImageOperations.COLOR_MAP)) {
                    img.setColorAdjustment(
                            localChanMap != null ? localChanMap : photo.getColorChannelMapping());
                }
                if (!appliedOps.contains(ImageOperations.CROP)) {
                    instanceRotation = ((CopyImageDescriptor) image).getRotation();
                    double rot = photo.getPrefRotation() - instanceRotation;
                    imageView.setRotation(rot);
                    imageView.setCrop(photo.getCropBounds());
                }
            } else {
                // This is original so we must apply corrections
                img.setColorAdjustment(localChanMap != null ? localChanMap : photo.getColorChannelMapping());
                imageView.setRotation(photo.getPrefRotation());
                imageView.setCrop(photo.getCropBounds());
            }
            setImage(img);
            fireViewChangeEvent();
            return;
        }
    }
    // if we get this far no instance of the original image has been found
    setImage(null);
    throw new PhotovaultException("No suitable instance of photo " + photo.getUuid() + " found");

}

From source file:edu.uci.ics.pregelix.core.driver.Driver.java

private void execute(JobSpecification job) throws Exception {
    job.setUseConnectorPolicyForScheduling(false);
    JobId jobId = hcc.startJob(job,/*from   ww  w .ja  v  a  2 s.  com*/
            profiling ? EnumSet.of(JobFlag.PROFILE_RUNTIME) : EnumSet.noneOf(JobFlag.class));
    hcc.waitForCompletion(jobId);
}

From source file:fr.ritaly.dungeonmaster.ai.CreatureManager.java

/**
 * Returns the sectors occupied by creatures.
 *
 * @return a set of sectors. Never returns null.
 */// w w  w  . j av  a 2 s .  co  m
public EnumSet<Sector> getOccupiedSectors() {
    return (creatures != null) ? EnumSet.copyOf(creatures.keySet()) : EnumSet.noneOf(Sector.class);
}

From source file:org.apache.sentry.policy.indexer.TestIndexerAuthorizationProviderGeneralCases.java

@Test
public void testJuniorAnalyst() throws Exception {
    Set<IndexerModelAction> allActions = EnumSet.allOf(IndexerModelAction.class);
    doTestAuthProviderOnIndexer(SUB_JUNIOR_ANALYST, IND_JRANALYST1, allActions);

    Set<IndexerModelAction> readOnly = EnumSet.of(IndexerModelAction.READ);
    doTestAuthProviderOnIndexer(SUB_JUNIOR_ANALYST, IND_PURCHASES_PARTIAL, readOnly);

    Set<IndexerModelAction> noActions = EnumSet.noneOf(IndexerModelAction.class);
    doTestAuthProviderOnIndexer(SUB_JUNIOR_ANALYST, IND_PURCHASES, noActions);
    doTestAuthProviderOnIndexer(SUB_JUNIOR_ANALYST, IND_ANALYST1, noActions);
    doTestAuthProviderOnIndexer(SUB_JUNIOR_ANALYST, IND_TMP, noActions);
}

From source file:org.apache.sentry.policy.search.TestSearchAuthorizationProviderGeneralCases.java

@Test
public void testJuniorAnalyst() throws Exception {
    Set<SearchModelAction> allActions = EnumSet.allOf(SearchModelAction.class);
    doTestAuthProviderOnCollection(SUB_JUNIOR_ANALYST, COLL_JRANALYST1, allActions);

    Set<SearchModelAction> queryOnly = EnumSet.of(SearchModelAction.QUERY);
    doTestAuthProviderOnCollection(SUB_JUNIOR_ANALYST, COLL_PURCHASES_PARTIAL, queryOnly);

    Set<SearchModelAction> noActions = EnumSet.noneOf(SearchModelAction.class);
    doTestAuthProviderOnCollection(SUB_JUNIOR_ANALYST, COLL_PURCHASES, noActions);
    doTestAuthProviderOnCollection(SUB_JUNIOR_ANALYST, COLL_ANALYST1, noActions);
    doTestAuthProviderOnCollection(SUB_JUNIOR_ANALYST, COLL_TMP, noActions);
}

From source file:jails.http.HttpHeaders.java

/**
 * Return the set of allowed {@link HttpMethod HTTP methods}, as specified by the {@code Allow} header.
 * <p>Returns an empty set when the allowed methods are unspecified.
 * @return the allowed methods// w w w  . ja  v a 2  s. com
 */
public Set<HttpMethod> getAllow() {
    String value = getFirst(ALLOW);
    if (value != null) {
        List<HttpMethod> allowedMethod = new ArrayList<HttpMethod>(5);
        String[] tokens = value.split(",\\s*");
        for (String token : tokens) {
            allowedMethod.add(HttpMethod.valueOf(token));
        }
        return EnumSet.copyOf(allowedMethod);
    } else {
        return EnumSet.noneOf(HttpMethod.class);
    }
}