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.opengamma.engine.exec.DefaultAggregatedExecutionLog.java

/**
 * Constructs an instance for a root level with possible logs from its dependencies when the full logging mode is being used.
 * // ww  w  .j av a2  s  .  c om
 * @param node the node this log has come from, not null
 * @param rootLog the root log, not null
 * @param dependentLogs the dependent logs, if any, may be null or empty
 * @return the log instance
 */
public static DefaultAggregatedExecutionLog fullLogMode(DependencyNode node, ExecutionLog rootLog,
        Collection<AggregatedExecutionLog> dependentLogs) {
    ArgumentChecker.notNull(node, "node");
    ArgumentChecker.notNull(rootLog, "rootLog");
    EnumSet<LogLevel> logLevels = rootLog.getLogLevels();
    boolean logLevelsCopied = false;
    final List<ExecutionLogWithContext> logs = new ArrayList<ExecutionLogWithContext>();
    boolean emptyRoot = rootLog.isEmpty();
    if (!emptyRoot) {
        logs.add(ExecutionLogWithContext.of(node, rootLog));
    }
    if (dependentLogs != null) {
        for (AggregatedExecutionLog dependentLog : dependentLogs) {
            final EnumSet<LogLevel> dependentLogLevels = dependentLog.getLogLevels();
            if (logLevelsCopied) {
                logLevels.addAll(dependentLogLevels);
            } else {
                if (!logLevels.equals(dependentLogLevels)) {
                    logLevels = EnumSet.copyOf(logLevels);
                    logLevels.addAll(dependentLogLevels);
                    logLevelsCopied = true;
                }
            }
            if (logs != null && dependentLog.getLogs() != null) {
                logs.addAll(dependentLog.getLogs());
            }
        }
    }
    return new DefaultAggregatedExecutionLog(logLevels, logs, emptyRoot);
}

From source file:org.apache.james.mailbox.model.MailboxACL.java

private static EnumSet<Right> copyOf(Collection<Right> collection) {
    if (collection.isEmpty()) {
        return EnumSet.noneOf(Right.class);
    }//from ww  w.ja va 2  s  . c  o m
    return EnumSet.copyOf(collection);
}

From source file:org.smurn.pokerutils.Hand.java

/**
 * Creates a hand./*from   ww w .ja va  2  s.co  m*/
 * Note that this constructor does not guarantee that the
 * hand is valid or even possible.
 * @param category Category of this hand. Must not be null.
 * @param cards Cards that form this hand. Must not be null, size must be 5.
 * @param ranks Ranks for the loxiographic ordering
 * (see {@link #getRanks()}. Must not be null.
 */
public Hand(final HandCategory category, final Collection<Card> cards, final List<Rank> ranks) {
    if (category == null) {
        throw new NullArgumentException("category");
    }
    if (cards == null) {
        throw new NullArgumentException("cards");
    }
    if (ranks == null) {
        throw new NullArgumentException("ranks");
    }
    if (cards.size() != CARDS_IN_HAND) {
        throw new IllegalArgumentException("cards must be of size 5, " + "but is " + cards.size() + ".");
    }

    this.category = category;
    this.cards = Collections.unmodifiableSet(EnumSet.copyOf(cards));
    this.ranks = Collections.unmodifiableList(new ArrayList<Rank>(ranks));
}

From source file:com.github.fge.ftpfs.io.commonsnetimpl.CommonsNetFtpFileView.java

@Override
public Collection<AccessMode> getAccess() {
    final EnumSet<AccessMode> ret = EnumSet.noneOf(AccessMode.class);
    next: for (final int type : ACCESS_TYPES)
        for (final Map.Entry<Integer, AccessMode> entry : ACCESS_MAP.entrySet())
            if (ftpFile.hasPermission(type, entry.getKey())) {
                ret.add(entry.getValue());
                continue next;
            }//from ww  w  . java  2s.c om

    return EnumSet.copyOf(ret);
}

From source file:org.eel.kitchen.jsonschema.validator.ValidationContext.java

/**
 * Create a validation context with a defined set of features
 *
 * @param cache the validator cache to use
 * @param features the feature set/*w ww  . j a  v  a2 s .c o m*/
 */
public ValidationContext(final JsonValidatorCache cache, final EnumSet<ValidationFeature> features) {
    this.cache = cache;
    this.features = EnumSet.copyOf(features);
    attributes = ImmutableMap.copyOf(FormatBundle.defaultBundle().getAttributes());
}

From source file:ch.cyberduck.core.s3.S3DirectoryFeature.java

@Override
public Path mkdir(final Path folder, final String region, final TransferStatus status)
        throws BackgroundException {
    if (containerService.isContainer(folder)) {
        final S3BucketCreateService service = new S3BucketCreateService(session);
        service.create(folder,//from   ww  w.j av a  2  s . c  om
                StringUtils.isBlank(region) ? PreferencesFactory.get().getProperty("s3.location") : region);
        return folder;
    } else {
        if (Checksum.NONE == status.getChecksum()) {
            status.setChecksum(writer.checksum(folder).compute(new NullInputStream(0L), status));
        }
        // Add placeholder object
        status.setMime(MIMETYPE);
        final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(folder.getType());
        type.add(Path.Type.placeholder);
        final Path placeholder = new Path(folder.getParent(), folder.getName(), type,
                new PathAttributes(folder.attributes()));
        new DefaultStreamCloser().close(writer.write(placeholder, status, new DisabledConnectionCallback()));
        return placeholder;
    }
}

From source file:com.github.fge.jsonschema.core.keyword.syntax.checkers.AbstractSyntaxChecker.java

@Override
public final EnumSet<NodeType> getValidTypes() {
    return EnumSet.copyOf(types);
}

From source file:ch.cyberduck.core.azure.AzureDirectoryFeature.java

@Override
public Path mkdir(final Path folder, final String region, final TransferStatus status)
        throws BackgroundException {
    try {/*from  ww w . java2 s .  c  om*/
        final BlobRequestOptions options = new BlobRequestOptions();
        if (containerService.isContainer(folder)) {
            // Container name must be lower case.
            final CloudBlobContainer container = session.getClient()
                    .getContainerReference(containerService.getContainer(folder).getName());
            container.create(options, context);
        } else {
            if (Checksum.NONE == status.getChecksum()) {
                status.setChecksum(writer.checksum(folder).compute(new NullInputStream(0L), status));
            }
            final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(folder.getType());
            type.add(Path.Type.placeholder);
            final Path placeholder = new Path(folder.getParent(), folder.getName(), type,
                    new PathAttributes(folder.attributes()));
            new DefaultStreamCloser()
                    .close(writer.write(placeholder, status, new DisabledConnectionCallback()));
            return placeholder;
        }
    } catch (URISyntaxException e) {
        throw new NotfoundException(e.getMessage(), e);
    } catch (StorageException e) {
        throw new AzureExceptionMappingService().map("Cannot create folder {0}", e, folder);
    }
    return folder;
}

From source file:com.github.rolecraftdev.guild.GuildRank.java

/**
 * Obtain the {@link GuildAction}s members of this {@link GuildRank} may
 * perform.//from   w w  w. java2 s. c  o m
 *
 * @return the permitted {@link GuildAction}s
 * @since 0.0.5
 */
@Nonnull
public Set<GuildAction> getPermittedActions() {
    return EnumSet.copyOf(permitted);
}

From source file:net.ripe.rpki.commons.crypto.x509cert.GenericRpkiCertificateBuilder.java

public void withInheritedResourceTypes(EnumSet<IpResourceType> resourceTypes) {
    this.inheritedResourceTypes = EnumSet.copyOf(resourceTypes);
}