Example usage for java.util EnumSet allOf

List of usage examples for java.util EnumSet allOf

Introduction

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

Prototype

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

Source Link

Document

Creates an enum set containing all of the elements in the specified element type.

Usage

From source file:Numbers.java

public static void main(String[] args) {

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

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

    EnumSet<Numbers> set2 = set1.clone();

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

}

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 empty
    EnumSet<Numbers> set2 = EnumSet.noneOf(Numbers.class);

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

}

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

public static void main(String[] args) {

    // create an empty EnumSet 
    EnumSet<Numbers> set = null;

    System.out.println(set);/*from ww w. j  a  v a2  s  .  c o  m*/

    // create the set by getting all elements from Numbers
    set = EnumSet.allOf(Numbers.class);

    // print the updated set
    System.out.println(set);

}

From source file:edu.harvard.med.screensaver.io.screens.ScreenCreator.java

@SuppressWarnings("static-access")
public static void main(String[] args) throws ParseException {
    final CommandLineApplication app = new CommandLineApplication(args);

    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("first name")
            .withLongOpt("lead-screener-first-name").create("lf"));
    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("last name")
            .withLongOpt("lead-screener-last-name").create("ll"));
    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("email")
            .withLongOpt("lead-screener-email").create("le"));

    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("first name")
            .withLongOpt("lab-head-first-name").create("hf"));
    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("last name")
            .withLongOpt("lab-head-last-name").create("hl"));
    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("email")
            .withLongOpt("lab-head-email").create("he"));

    List<String> desc = new ArrayList<String>();
    for (ScreenType t : EnumSet.allOf(ScreenType.class))
        desc.add(t.name());//w  ww.ja  v a 2 s  .co  m
    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("screen type")
            .withLongOpt("screen-type").withDescription(StringUtils.makeListString(desc, ", ")).create("st"));
    app.addCommandLineOption(
            OptionBuilder.hasArg().isRequired().withArgName("summary").withLongOpt("summary").create("s"));
    app.addCommandLineOption(
            OptionBuilder.hasArg().isRequired().withArgName("title").withLongOpt("title").create("t"));
    app.addCommandLineOption(
            OptionBuilder.hasArg().withArgName("protocol").withLongOpt("protocol").create("p"));
    app.addCommandLineOption(
            OptionBuilder.hasArg().isRequired().withArgName("#").withLongOpt("facilityId").create("i"));
    app.addCommandLineOption(OptionBuilder.hasArg(false).withLongOpt("replace")
            .withDescription("replace an existing Screen with the same facilityId").create("r"));

    app.processOptions(/* acceptDatabaseOptions= */false, /* acceptAdminUserOptions= */true);

    try {
        execute(app);
    } catch (Exception e) {
        log.error("Failed to create the screen", e);
        System.exit(1);
    }

}

From source file:edu.harvard.med.screensaver.io.screens.StudyCreator.java

@SuppressWarnings("static-access")
public static void main(String[] args) {
    final CommandLineApplication app = new CommandLineApplication(args);

    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("first name")
            .withLongOpt("lead-screener-first-name").create("lf"));
    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("last name")
            .withLongOpt("lead-screener-last-name").create("ll"));
    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("email")
            .withLongOpt("lead-screener-email").create("le"));

    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("first name")
            .withLongOpt("lab-head-first-name").create("hf"));
    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("last name")
            .withLongOpt("lab-head-last-name").create("hl"));
    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("email")
            .withLongOpt("lab-head-email").create("he"));

    List<String> desc = new ArrayList<String>();
    for (ScreenType t : EnumSet.allOf(ScreenType.class))
        desc.add(t.name());//from www  .  ja v a 2s . c o  m
    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("screen type")
            .withLongOpt("screen-type").withDescription(StringUtils.makeListString(desc, ", ")).create("y"));
    desc.clear();
    for (StudyType t : EnumSet.allOf(StudyType.class))
        desc.add(t.name());
    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("study type")
            .withLongOpt("study-type").withDescription(StringUtils.makeListString(desc, ", ")).create("yy"));
    app.addCommandLineOption(
            OptionBuilder.hasArg().isRequired().withArgName("summary").withLongOpt("summary").create("s"));
    app.addCommandLineOption(
            OptionBuilder.hasArg().isRequired().withArgName("title").withLongOpt("title").create("t"));
    app.addCommandLineOption(
            OptionBuilder.hasArg().withArgName("protocol").withLongOpt("protocol").create("p"));
    app.addCommandLineOption(
            OptionBuilder.hasArg().isRequired().withArgName("#").withLongOpt("facilityId").create("i"));
    app.addCommandLineOption(OptionBuilder.hasArg(false).withLongOpt("replace")
            .withDescription("replace an existing Screen with the same facilityId").create("r"));

    app.addCommandLineOption(OptionBuilder.withLongOpt("key-input-by-wellkey")
            .withDescription("default value is to key by reagent vendor id").create("keyByWellId"));
    app.addCommandLineOption(OptionBuilder.withLongOpt("key-input-by-facility-id")
            .withDescription("default value is to key by reagent vendor id").create("keyByFacilityId"));
    app.addCommandLineOption(OptionBuilder.withLongOpt("key-input-by-compound-name")
            .withDescription("default value is to key by reagent vendor id").create("keyByCompoundName"));
    app.addCommandLineOption(OptionBuilder.withDescription(
            "optional: pivot the input col/rows so that the AT names are in Col1, and the AT well_id/rvi's are in Row1")
            .withLongOpt("annotation-names-in-col1").create("annotationNamesInCol1"));
    app.addCommandLineOption(OptionBuilder.hasArg().withArgName("file").withLongOpt("data-file").create("f"));

    app.addCommandLineOption(OptionBuilder.withArgName("parseLincsSpecificFacilityID")
            .withLongOpt("parseLincsSpecificFacilityID").create("parseLincsSpecificFacilityID"));
    app.processOptions(/* acceptDatabaseOptions= */true, /* acceptAdminUserOptions= */true);
    execute(app);
}

From source file:Main.java

public static <E extends Enum<E>> boolean contains(Class<E> _enumClass, String value) {
    try {/*from  ww  w .j a va  2  s  .  c  om*/
        return EnumSet.allOf(_enumClass).contains(Enum.valueOf(_enumClass, value));
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static <E extends Enum<E>> Set<E> immutableEnumSet(Class<E> enumClass) {
    return ImmutableSet.copyOf(EnumSet.allOf(enumClass));
}

From source file:Main.java

private static <T extends Enum<T>> EnumSet bitwiseToEnumSet(Class<T> classType, int bitwise) {
    EnumSet<T> enumSet = EnumSet.noneOf(classType);
    for (T enumValue : EnumSet.allOf(classType)) {
        if ((bitwise & (int) Math.pow(2, enumValue.ordinal())) == (int) Math.pow(2, enumValue.ordinal()))
            enumSet.add(enumValue);//from   www.  j a  v  a  2s .  c o m
    }
    return enumSet;
}

From source file:Main.java

public static <E extends Enum<E>> EnumSet<E> createEnumSet(Class<E> elementType) {
    if (elementType == null) {
        return null;
    }/*from  w ww .j av a2  s . c o m*/

    return EnumSet.allOf(elementType);
}