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:Numbers.java

public static void main(String[] args) {

    EnumSet<Numbers> set1 = EnumSet.allOf(Numbers.class);

    System.out.println("Set1:" + set1);

    // create a second set which is a copy of set1
    EnumSet<Numbers> set2 = EnumSet.copyOf(set1);

    System.out.println("Set2:" + set2);

}

From source file:Main.java

public static <E extends Enum<E>> EnumSet<E> createEnumSet(Collection<E> c) {
    if (c == null) {
        return null;
    }//from  ww  w . j  a  v  a  2  s.  co  m

    return EnumSet.copyOf(c);
}

From source file:Main.java

/**
 * Returns an unmodifiable versions of the Set of Enums.  If the contents of the set are known
 * to be unmodifiable by the caller in any way, the set itself will be retured, otherwise an
 * unmodifiable copy of the Set will be returned.
 * @param s Set to get the tamper-proof version of
 * @return An unmodifiable tamper-proof version of the set
 *///  www. ja va 2 s .  c  o  m
public static <E extends Enum<E>> Set<E> unmodifiableCopyOfEnumSet(Set<E> s) {
    Class<? extends Set> copyClass = s.getClass();

    if ((_EMPTY_SET == copyClass) || (_SINGLETON_SET == copyClass)) {
        // these classes are already unmodifiable, so just return
        return s;
    } else {
        return Collections.unmodifiableSet(EnumSet.copyOf(s));
    }
}

From source file:com.book.identification.FileFilter.java

public FileFilter(FileType... fileType) {
    super();
    this.fileTypes = EnumSet.copyOf(Arrays.asList(fileType));
}

From source file:com.github.fge.jsonschema.keyword.digest.AbstractDigester.java

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

From source file:org.eel.kitchen.jsonschema.syntax.ArrayChildrenSyntaxChecker.java

protected ArrayChildrenSyntaxChecker(final String keyword, final EnumSet<NodeType> childrenTypes,
        final NodeType type, final NodeType... types) {
    super(keyword, type, types);
    this.childrenTypes = EnumSet.copyOf(childrenTypes);
}

From source file:ch.cyberduck.core.DefaultPathReference.java

private String type() {
    final EnumSet<Path.Type> types = EnumSet.copyOf(file.getType());
    types.remove(Path.Type.placeholder);
    types.remove(Path.Type.volume);
    return String.valueOf(types);
}

From source file:ch.cyberduck.core.DefaultPathPredicate.java

protected String type() {
    final EnumSet<Path.Type> types = EnumSet.copyOf(file.getType());
    types.remove(Path.Type.placeholder);
    types.remove(Path.Type.volume);
    types.remove(Path.Type.encrypted);
    types.remove(Path.Type.decrypted);
    types.remove(Path.Type.vault);
    types.remove(Path.Type.upload);
    return String.valueOf(types);
}

From source file:org.trnltk.model.lexicon.DynamicLexeme.java

public DynamicLexeme(final DynamicLexeme other) {
    this.lemma = other.lemma;
    this.lemmaRoot = other.lemmaRoot;
    this.primaryPos = other.primaryPos;
    this.secondaryPos = other.secondaryPos;
    this.lexemeAttributes = EnumSet.copyOf(other.lexemeAttributes);
}

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

/**
 * Constructor, package private/*  w w w  . j  a va2s  . c  o  m*/
 *
 * @param cache the validator cache
 * @param features the feature set
 * @param schemaNode the schema node
 */
JsonSchema(final JsonValidatorCache cache, final EnumSet<ValidationFeature> features,
        final SchemaNode schemaNode) {
    this.cache = cache;
    this.features = EnumSet.copyOf(features);
    this.schemaNode = schemaNode;
}