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:com.netflix.genie.core.jpa.services.JpaClusterServiceImplIntegrationTests.java

/**
 * Test the get clusters method./*from ww  w  . j a v a  2 s.c  om*/
 */
@Test
public void testGetClustersByStatuses() {
    final Set<ClusterStatus> statuses = EnumSet.noneOf(ClusterStatus.class);
    statuses.add(ClusterStatus.UP);
    final Page<Cluster> clusters = this.service.getClusters(null, statuses, null, null, null, PAGE);
    Assert.assertEquals(2, clusters.getNumberOfElements());
    Assert.assertEquals(CLUSTER_2_ID,
            clusters.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new));
    Assert.assertEquals(CLUSTER_1_ID,
            clusters.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new));
}

From source file:com.github.blindpirate.gogradle.util.IOUtils.java

public static void walkFileTreeSafely(Path path, FileVisitor<? super Path> visitor) {
    try {//from w  w  w .  j  a  v a 2  s .  co  m
        Files.walkFileTree(path, EnumSet.noneOf(FileVisitOption.class), MAX_DFS_DEPTH, visitor);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:org.lilyproject.runtime.configuration.ConfRegistryImpl.java

public synchronized void addListener(ConfListener listener, String path, ConfListener.ChangeType... types) {
    EnumSet<ChangeType> typesSet = EnumSet.noneOf(ChangeType.class);
    typesSet.addAll(Arrays.asList(types));

    listeners.add(new ListenerHandle(listener, path, typesSet));
}

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

/**
 * Get Applications based on user parameters.
 *
 * @param name      name for configuration (optional)
 * @param user      The user who created the application (optional)
 * @param statuses  The statuses of the applications (optional)
 * @param tags      The set of tags you want the application for. (optional)
 * @param type      The type of applications to get (optional)
 * @param page      The page to get/* www . jav a 2  s  .  c  om*/
 * @param assembler The paged resources assembler to use
 * @return All applications matching the criteria
 * @throws GenieException For any error
 */
@GetMapping(produces = MediaTypes.HAL_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public PagedResources<ApplicationResource> getApplications(
        @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,
        @RequestParam(value = "type", required = false) final String type,
        @PageableDefault(sort = { "updated" }, direction = Sort.Direction.DESC) final Pageable page,
        final PagedResourcesAssembler<Application> assembler) throws GenieException {
    log.debug("Called [name | user | status | tags | type | pageable]");
    log.debug("{} | {} | {} | {} | | {} | {}", name, user, statuses, tags, type, page);

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

    final Link self = ControllerLinkBuilder
            .linkTo(ControllerLinkBuilder.methodOn(ApplicationRestController.class).getApplications(name, user,
                    statuses, tags, type, page, assembler))
            .withSelfRel();

    return assembler.toResource(
            this.applicationService.getApplications(name, user, enumStatuses, tags, type, page),
            this.applicationResourceAssembler, self);
}

From source file:org.apache.accumulo.shell.commands.SetIterCommand.java

protected void setTableProperties(final CommandLine cl, final Shell shellState, final int priority,
        final Map<String, String> options, final String classname, final String name)
        throws AccumuloException, AccumuloSecurityException, ShellCommandException, TableNotFoundException {
    // remove empty values

    final String tableName = OptUtil.getTableOpt(cl, shellState);

    ScanCommand.ensureTserversCanLoadIterator(shellState, tableName, classname);

    final String aggregatorClass = options.get("aggregatorClass");
    @SuppressWarnings("deprecation")
    String deprecatedAggregatorClassName = org.apache.accumulo.core.iterators.aggregation.Aggregator.class
            .getName();/*from w  w w.  j  av  a 2 s  .c om*/
    if (aggregatorClass != null && !shellState.getConnector().tableOperations().testClassLoad(tableName,
            aggregatorClass, deprecatedAggregatorClassName)) {
        throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE,
                "Servers are unable to load " + aggregatorClass + " as type " + deprecatedAggregatorClassName);
    }

    for (Iterator<Entry<String, String>> i = options.entrySet().iterator(); i.hasNext();) {
        final Entry<String, String> entry = i.next();
        if (entry.getValue() == null || entry.getValue().isEmpty()) {
            i.remove();
        }
    }
    final EnumSet<IteratorScope> scopes = EnumSet.noneOf(IteratorScope.class);
    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(mincScopeOpt.getOpt())) {
        scopes.add(IteratorScope.minc);
    }
    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(majcScopeOpt.getOpt())) {
        scopes.add(IteratorScope.majc);
    }
    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(scanScopeOpt.getOpt())) {
        scopes.add(IteratorScope.scan);
    }
    if (scopes.isEmpty()) {
        throw new IllegalArgumentException("You must select at least one scope to configure");
    }
    final IteratorSetting setting = new IteratorSetting(priority, name, classname, options);
    shellState.getConnector().tableOperations().attachIterator(tableName, setting, scopes);
}

From source file:com.netflix.genie.core.services.impl.JobCoordinatorServiceImpl.java

/**
 * Constructor.//from w  ww  .ja v  a  2 s  .c  om
 *
 * @param jobPersistenceService implementation of job persistence service interface
 * @param jobKillService        The job kill service to use
 * @param jobStateService       The service where we report the job state and keep track of various metrics about
 *                              jobs currently running
 * @param jobsProperties        The jobs properties to use
 * @param applicationService    Implementation of application service interface
 * @param jobSearchService      Implementation of job search service
 * @param clusterService        Implementation of cluster service interface
 * @param commandService        Implementation of command service interface
 * @param clusterLoadBalancers  Implementations of the cluster load balancer interface in invocation order
 * @param registry              The registry
 * @param hostName              The name of the host this Genie instance is running on
 */
public JobCoordinatorServiceImpl(@NotNull final JobPersistenceService jobPersistenceService,
        @NotNull final JobKillService jobKillService, @NotNull final JobStateService jobStateService,
        @NotNull final JobsProperties jobsProperties, @NotNull final ApplicationService applicationService,
        @NotNull final JobSearchService jobSearchService, @NotNull final ClusterService clusterService,
        @NotNull final CommandService commandService,
        @NotNull @NotEmpty final List<ClusterLoadBalancer> clusterLoadBalancers,
        @NotNull final Registry registry, @NotBlank final String hostName) {
    this.jobPersistenceService = jobPersistenceService;
    this.jobKillService = jobKillService;
    this.jobStateService = jobStateService;
    this.applicationService = applicationService;
    this.jobSearchService = jobSearchService;
    this.clusterService = clusterService;
    this.commandService = commandService;
    this.clusterLoadBalancers = clusterLoadBalancers;
    this.jobsProperties = jobsProperties;
    this.hostName = hostName;

    // We'll only care about active statuses
    this.commandStatuses = EnumSet.noneOf(CommandStatus.class);
    this.commandStatuses.add(CommandStatus.ACTIVE);

    // Metrics
    this.registry = registry;
    this.coordinationTimerId = registry.createId("genie.jobs.coordination.timer");
    this.selectClusterTimerId = registry.createId("genie.jobs.submit.localRunner.selectCluster.timer");
    this.selectCommandTimerId = registry.createId("genie.jobs.submit.localRunner.selectCommand.timer");
    this.selectApplicationsTimerId = registry
            .createId("genie.jobs.submit.localRunner.selectApplications.timer");
    this.setJobEnvironmentTimerId = registry.createId("genie.jobs.submit.localRunner.setJobEnvironment.timer");
    this.loadBalancerCounterId = registry.createId("genie.jobs.submit.selectCluster.loadBalancer.counter");
    this.noClusterSelectedCounter = registry.counter("genie.jobs.submit.selectCluster.noneSelected.counter");
    this.noClusterFoundCounter = registry.counter("genie.jobs.submit.selectCluster.noneFound.counter");
}

From source file:com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.java

@Override
public String getShortDescription() {
    EnumSet<Type> s = EnumSet.noneOf(Type.class);
    for (Mapping m : mappings)
        s.add(m.getDo());/*from w  w  w .  j  a v a 2  s  .c o m*/

    StringBuilder sb = new StringBuilder();
    sb.append(TextUtil.capitalize(TextUtil.toEnglishList("or",
            s.contains(Type.REDIRECT_PERMANENT) || s.contains(Type.REDIRECT_TEMPORARY)
                    ? TextUtil.toEnglishList("or", s.contains(Type.REDIRECT_PERMANENT) ? "permanently" : null,
                            s.contains(Type.REDIRECT_TEMPORARY) ? "temporarily" : null) + " redirects"
                    : null,
            s.contains(Type.REWRITE) ? "rewrites" : null)));
    sb.append(" URLs.");
    return sb.toString();
}

From source file:org.photovault.imginfo.CreateCopyImageCommand.java

/**
 Execute the command. //  w w  w . j av a 2s. c  o m
 @throws CommandException If no image suitable for using as a source can be 
 found or if saving the created image does not succeed.
 */
public void execute() throws CommandException {
    // Find the image used as source for the new instance
    PhotoInfoDAO photoDAO = daoFactory.getPhotoInfoDAO();
    VolumeDAO volDAO = daoFactory.getVolumeDAO();
    photo = photoDAO.findByUUID(photoUuid);

    Set<ImageOperations> operationsNotApplied = EnumSet.copyOf(operationsToApply);
    ImageDescriptorBase srcImageDesc = photo.getOriginal();
    // Find a suitable image for using as source if the original has not
    // yet been loaded.
    if (img == null) {
        ImageFile srcImageFile = srcImageDesc.getFile();
        File src = srcImageFile.findAvailableCopy();
        if (src == null && !createFromOriginal) {
            srcImageDesc = photo.getPreferredImage(EnumSet.noneOf(ImageOperations.class), operationsToApply,
                    maxWidth, maxHeight, Integer.MAX_VALUE, Integer.MAX_VALUE);
            if (srcImageDesc != null) {
                srcImageFile = srcImageDesc.getFile();
                src = srcImageFile.findAvailableCopy();
                operationsNotApplied.removeAll(((CopyImageDescriptor) srcImageDesc).getAppliedOperations());
            }
        }
        if (src == null) {
            throw new CommandException("No suitable image file found");
        }

        // Create the image for the instance
        PhotovaultImageFactory imgFactory = new PhotovaultImageFactory();
        try {
            img = imgFactory.create(src, false, false);
        } catch (PhotovaultException ex) {
            throw new CommandException(ex.getMessage());
        }
    }
    if (operationsNotApplied.contains(ImageOperations.CROP)) {
        img.setCropBounds(photo.getCropBounds());
        img.setRotation(photo.getPrefRotation());
    }
    if (operationsNotApplied.contains(ImageOperations.COLOR_MAP)) {
        ChannelMapOperation channelMap = photo.getColorChannelMapping();
        if (channelMap != null) {
            img.setColorAdjustment(channelMap);
        }
    }
    if (operationsNotApplied.contains(ImageOperations.COLOR_MAP) && img instanceof RawImage) {
        RawImage ri = (RawImage) img;
        ri.setRawSettings(photo.getRawSettings());
    }

    RenderedImage renderedDst = img.getRenderedImage(maxWidth, maxHeight, lowQualityAllowed);

    // Determine correct file name for the image & save it

    if (volumeUuid != null) {
        VolumeBase vol = volDAO.findById(volumeUuid, false);
        dstFile = vol.getInstanceName(photo, "jpg");
    }
    if (dstFile == null) {
        throw new CommandException("Either destination file or volume must be specified");
    }

    ImageFileDAO ifDAO = daoFactory.getImageFileDAO();
    ImageFile dstImageFile = new ImageFile();
    ifDAO.makePersistent(dstImageFile);
    CopyImageDescriptor dstImage = new CopyImageDescriptor(dstImageFile, "image#0", photo.getOriginal());
    ImageDescriptorDAO idDAO = daoFactory.getImageDescriptorDAO();
    idDAO.makePersistent(dstImage);
    if (operationsToApply.contains(ImageOperations.COLOR_MAP)) {
        dstImage.setColorChannelMapping(photo.getColorChannelMapping());
    }
    if (operationsToApply.contains(ImageOperations.CROP)) {
        dstImage.setCropArea(photo.getCropBounds());
        dstImage.setRotation(photo.getPrefRotation());
    }
    if (operationsToApply.contains(ImageOperations.RAW_CONVERSION)) {
        dstImage.setRawSettings(photo.getRawSettings());
    }
    dstImage.setWidth(renderedDst.getWidth());
    dstImage.setHeight(renderedDst.getHeight());
    ((CopyImageDescriptor) dstImageFile.getImages().get("image#0")).setOriginal(photo.getOriginal());
    byte[] xpmData = createXMPMetadata(dstImageFile);

    try {
        saveImage(dstFile, renderedDst, xpmData);
    } catch (PhotovaultException ex) {
        throw new CommandException(ex.getMessage());
    } finally {
        img.dispose();
    }

    /*
     Check if the resulting image file is already known & create a new one
     if not
     */
    byte[] hash = ImageFile.calcHash(dstFile);
    dstImageFile.setHash(hash);

    /*
     Store location of created file in database
     */
    if (volume != null) {
        dstImageFile.addLocation(volume.getFileLocation(dstFile));
    }

    /*
     Ensure that the photo is initialized in memory as it is used as a 
     detached object after closing our persistence context.         
     */
    if (!photo.hasThumbnail()) {
        log.error("No valid thumbnail available!!!");
    }
}

From source file:uk.co.modularaudio.service.jnajackaudioprovider.JNAJackAudioProvider.java

@Override
public void init() throws ComponentConfigurationException {
    if (configurationService == null || audioProviderRegistryService == null || timingService == null) {
        final String msg = "JNAJackAudioProvider is missing service dependencies. Please check configuration";
        log.error(msg);/* w w  w .ja  va 2s.co  m*/
        throw new ComponentConfigurationException(msg);
    }

    try {

        final Map<String, String> errors = new HashMap<String, String>();

        doConnect = ConfigurationServiceHelper.checkForBooleanKey(configurationService, CONFIG_KEY_DO_CONNECT,
                errors);

        ConfigurationServiceHelper.errorCheck(errors);

        consumerAudioHardwareDevices.add(new AudioHardwareDevice(this.getId(), "jnajackout8",
                "JNAJack " + NUM_SURROUND_JACK_AUDIO_CHANNELS + " Channel Output", DeviceDirection.CONSUMER,
                NUM_SURROUND_JACK_AUDIO_CHANNELS));

        producerAudioHardwareDevices.add(new AudioHardwareDevice(this.getId(), "jnajackin8",
                "JNAJack " + NUM_SURROUND_JACK_AUDIO_CHANNELS + " Channel Input", DeviceDirection.PRODUCER,
                NUM_SURROUND_JACK_AUDIO_CHANNELS));

        consumerAudioHardwareDevices.add(new AudioHardwareDevice(this.getId(), "jnajackout4",
                "JNAJack " + NUM_QUAD_JACK_AUDIO_CHANNELS + " Channel Output", DeviceDirection.CONSUMER,
                NUM_QUAD_JACK_AUDIO_CHANNELS));

        producerAudioHardwareDevices.add(new AudioHardwareDevice(this.getId(), "jnajackin4",
                "JNAJack " + NUM_QUAD_JACK_AUDIO_CHANNELS + " Channel Input", DeviceDirection.PRODUCER,
                NUM_QUAD_JACK_AUDIO_CHANNELS));

        consumerAudioHardwareDevices.add(new AudioHardwareDevice(this.getId(), "jnajackout2",
                "JNAJack " + NUM_STEREO_JACK_AUDIO_CHANNELS + " Channel Output", DeviceDirection.CONSUMER,
                NUM_STEREO_JACK_AUDIO_CHANNELS));

        producerAudioHardwareDevices.add(new AudioHardwareDevice(this.getId(), "jnajackin2",
                "JNAJack " + NUM_STEREO_JACK_AUDIO_CHANNELS + " Channel Input", DeviceDirection.PRODUCER,
                NUM_STEREO_JACK_AUDIO_CHANNELS));

        consumerMidiHardwareDevices.add(new MidiHardwareDevice(this.getId(), "jnajackmidiout",
                "JNAJack Midi Output", DeviceDirection.CONSUMER));

        producerMidiHardwareDevices.add(new MidiHardwareDevice(this.getId(), "jnajackmidiin",
                "JNAJack Midi Input", DeviceDirection.PRODUCER));

        if (doConnect) {
            jack = Jack.getInstance();

            final EnumSet<JackOptions> options = EnumSet.of(JackOptions.JackNoStartServer);
            final EnumSet<JackStatus> status = EnumSet.noneOf(JackStatus.class);
            client = jack.openClient(jackClientName, options, status, new Object[] {});

            if (client != null) {
                connectedToJack = true;
            }
        }
        try {
            audioProviderRegistryService.registerAudioProvider(this);
        } catch (final Exception e) {
            log.error(e);
        }
    } catch (final JackException je) {
        final String msg = "JackException caught during JNAJackAudioProvider init()";
        log.error(msg, je);
        throw new ComponentConfigurationException(msg, je);
    }
}

From source file:com.amazonaws.services.dynamodbv2.datamodeling.AttributeEncryptor.java

private <T> ModelClassMetadata getModelClassMetadata(Parameters<T> parameters) {
    // Due to the lack of explicit synchronization, it is possible that
    // elements in the cache will be added multiple times. Since they will
    // all be identical, this is okay. Avoiding explicit synchronization
    // means that in the general (retrieval) case, should never block and
    // should be extremely fast.
    final Class<T> clazz = parameters.getModelClass();
    ModelClassMetadata metadata = metadataCache.get(clazz);

    if (metadata == null) {
        Map<String, Set<EncryptionFlags>> attributeFlags = new HashMap<>();

        final boolean handleUnknownAttributes = handleUnknownAttributes(clazz);
        final EnumSet<EncryptionFlags> unknownAttributeBehavior = EnumSet.noneOf(EncryptionFlags.class);

        if (shouldTouch(clazz)) {
            Mappings mappings = DynamoDBMappingsRegistry.instance().mappingsOf(clazz);

            for (Mapping mapping : mappings.getMappings()) {
                final EnumSet<EncryptionFlags> flags = EnumSet.noneOf(EncryptionFlags.class);
                if (shouldTouch(mapping)) {
                    if (shouldEncryptAttribute(clazz, mapping)) {
                        flags.add(EncryptionFlags.ENCRYPT);
                    }/*from   www .j a  v  a  2 s. c  om*/
                    flags.add(EncryptionFlags.SIGN);
                }
                attributeFlags.put(mapping.getAttributeName(), Collections.unmodifiableSet(flags));
            }

            if (handleUnknownAttributes) {
                unknownAttributeBehavior.add(EncryptionFlags.SIGN);

                if (shouldEncrypt(clazz)) {
                    unknownAttributeBehavior.add(EncryptionFlags.ENCRYPT);
                }
            }
        }

        metadata = new ModelClassMetadata(Collections.unmodifiableMap(attributeFlags), doNotTouch(clazz),
                Collections.unmodifiableSet(unknownAttributeBehavior));
        metadataCache.put(clazz, metadata);
    }
    return metadata;
}