Example usage for java.util EnumSet copyOf

List of usage examples for java.util EnumSet copyOf

Introduction

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

Prototype

public static <E extends Enum<E>> EnumSet<E> copyOf(Collection<E> c) 

Source Link

Document

Creates an enum set initialized from the specified collection.

Usage

From source file:com.navercorp.pinpoint.common.server.util.AgentEventType.java

private Set<AgentEventTypeCategory> asSet(AgentEventTypeCategory[] category) {
    if (ArrayUtils.isEmpty(category)) {
        return Collections.emptySet();
    }/*from w  ww.ja  v  a 2 s.  c o  m*/
    return EnumSet.copyOf(Arrays.asList(category));
}

From source file:ezbake.data.elastic.security.EzSecurityVisibilityFilter.java

public EzSecurityVisibilityFilter(Map<String, Object> params, ESLogger logger) {
    this.logger = logger;

    if (params == null) {
        throw new IllegalArgumentException("Script parameters may not be null");
    }//from   w  ww.j  a v  a 2 s  .  co  m

    visibilityField = (String) params.get(VISIBILITY_FIELD_PARAM);
    if (StringUtils.isEmpty(visibilityField)) {
        throw new IllegalArgumentException("Visibility must be given");
    }

    final String requiredPermsParam = (String) params.get(REQUIRED_PERMISSIONS_PARAM);
    if (StringUtils.isEmpty(requiredPermsParam)) {
        throw new IllegalArgumentException("Required permissions must be given");
    }

    final String[] requiredPermNamesArray = StringUtils.split(requiredPermsParam, ',');
    final List<String> requiredPermNames = Lists.newArrayList(requiredPermNamesArray);

    final List<Permission> requiredPermsList = Lists.transform(requiredPermNames,
            new Function<String, Permission>() {
                @Override
                public Permission apply(String input) {
                    return Permission.valueOf(input);
                }
            });

    requiredPermissions = EnumSet.copyOf(requiredPermsList);

    final String authsBase64 = (String) params.get(AUTHS_PARAM);
    try {
        authorizations = deserializeFromBase64(Authorizations.class, authsBase64);
    } catch (final TException e) {
        final String errMsg = "Could not deserialize authorizations parameter to Authorizations Thrift";
        this.logger.error(errMsg, e);
        throw new IllegalArgumentException(errMsg, e);
    }

    evaluator = new PermissionEvaluator(authorizations);
    serializer = new CachingSerializer<>(new Base64Serializer());
}

From source file:com.opengamma.engine.calcnode.MutableExecutionLog.java

@Override
public EnumSet<LogLevel> getLogLevels() {
    return EnumSet.copyOf(_logLevels);
}

From source file:org.eel.kitchen.jsonschema.main.JsonSchemaFactory.java

/**
 * Constructor, private by design/*from w  ww. j av  a2 s.c o  m*/
 *
 * @see JsonSchemaFactory.Builder
 * @param builder the builder
 */
private JsonSchemaFactory(final Builder builder) {
    registry = new SchemaRegistry(builder.uriManager, builder.namespace);
    cache = new JsonValidatorCache(builder.keywordBundle, registry);
    features = EnumSet.copyOf(builder.features);
}

From source file:ch.cyberduck.core.b2.B2DirectoryFeature.java

@Override
public Path mkdir(final Path folder, final String region, final TransferStatus status)
        throws BackgroundException {
    try {/*w w  w  .  ja v a  2 s  .co  m*/
        if (containerService.isContainer(folder)) {
            final B2BucketResponse response = session.getClient().createBucket(
                    containerService.getContainer(folder).getName(),
                    null == region
                            ? BucketType.valueOf(PreferencesFactory.get().getProperty("b2.bucket.acl.default"))
                            : BucketType.valueOf(region));
            switch (response.getBucketType()) {
            case allPublic:
                folder.attributes().setAcl(
                        new Acl(new Acl.GroupUser(Acl.GroupUser.EVERYONE, false), new Acl.Role(Acl.Role.READ)));
            }
            return new Path(folder.getParent(), folder.getName(), folder.getType(),
                    new PathAttributes(folder.attributes()));
        } else {
            if (Checksum.NONE == status.getChecksum()) {
                status.setChecksum(writer.checksum(folder).compute(new NullInputStream(0L), status));
            }
            status.setMime(MimeTypeService.DEFAULT_CONTENT_TYPE);
            new DefaultStreamCloser().close(writer.write(folder, status, new DisabledConnectionCallback()));
            final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(folder.getType());
            type.add(Path.Type.placeholder);
            return new Path(folder.getParent(), folder.getName(), type,
                    new PathAttributes(folder.attributes()));
        }
    } catch (B2ApiException e) {
        throw new B2ExceptionMappingService().map("Cannot create folder {0}", e, folder);
    } catch (IOException e) {
        throw new DefaultIOExceptionMappingService().map(e);
    }
}

From source file:com.autentia.common.statemachine.StateMachine.java

@SuppressWarnings("unchecked")
protected StateMachine(T initialState, T... finalStates) {
    Assert.notNull(initialState, "initialState cannot be null");
    Assert.notEmpty(finalStates, "finalState cannot be null");

    this.enumClass = (Class<T>) initialState.getClass();
    this.initialState = initialState;
    this.finalStates = EnumSet.copyOf(Arrays.asList(finalStates));

    states = new EnumMap<T, Pair<State<T>, List<Transition<T>>>>(enumClass);
    createStateMachine();//from  w w w .j a  v a  2s .  c  o m
    checkConsistency();
}

From source file:com.github.anba.es6draft.util.TestGlobals.java

protected EnumSet<CompatibilityOption> getOptions() {
    return EnumSet.copyOf(options);
}

From source file:org.trnltk.morphology.phonetics.PhoneticsAnalyzerDistinctionTest.java

private Set<EnumSet<PhoneticAttribute>> getDistinctPhoneticAttributeSetsFromMasterDictionary() {
    final HashMultimap<String, ? extends Root> rootMap = RootMapFactory
            .createSimpleWithNumbersConvertCircumflexes();
    final Collection<? extends Root> roots = rootMap.values();

    final Set<EnumSet<PhoneticAttribute>> distinctPhonAttrs = new HashSet<EnumSet<PhoneticAttribute>>();

    for (Root root : roots) {
        distinctPhonAttrs.add(EnumSet.copyOf(root.getPhoneticAttributes()));
    }/*from   w  w w . j  av  a 2  s  . c o  m*/
    return distinctPhonAttrs;
}

From source file:com.github.fge.jsonschema.core.load.configuration.LoadingConfigurationBuilder.java

/**
 * Return a new, default mutable loading configuration
 *
 * @see LoadingConfiguration#newBuilder()
 *//*from   www. j  a va  2  s .c  o m*/
LoadingConfigurationBuilder() {
    translatorCfg = URITranslatorConfiguration.byDefault();
    dereferencing = Dereferencing.CANONICAL;
    preloadedSchemas = Maps.newHashMap();
    for (final SchemaVersion version : SchemaVersion.values())
        preloadedSchemas.put(version.getLocation(), version.getSchema());
    parserFeatures = EnumSet.copyOf(DEFAULT_PARSER_FEATURES);
}

From source file:com.hortonworks.streamline.streams.security.catalog.AclEntry.java

public void setPermissions(EnumSet<Permission> permissions) {
    this.permissions = EnumSet.copyOf(permissions);
}