Example usage for java.util EnumSet of

List of usage examples for java.util EnumSet of

Introduction

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

Prototype

@SafeVarargs
public static <E extends Enum<E>> EnumSet<E> of(E first, E... rest) 

Source Link

Document

Creates an enum set initially containing the specified elements.

Usage

From source file:Numbers.java

public static void main(String[] args) {

    // create a set
    EnumSet<Numbers> set;/*from w  w  w. ja v  a  2 s  .  c om*/

    // add elements
    set = EnumSet.of(Numbers.FIVE, Numbers.FOUR);

    System.out.println(set);

}

From source file:Main.java

public static void main(String[] args) {
    final EnumSet<Style> styles = EnumSet.noneOf(Style.class);
    styles.addAll(EnumSet.range(Style.BOLD, Style.STRIKETHROUGH));
    styles.removeAll(EnumSet.of(Style.UNDERLINE, Style.STRIKETHROUGH));
    assert EnumSet.of(Style.BOLD, Style.ITALIC).equals(styles);
    System.out.println(styles);//from  ww  w .j a va 2 s . com
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Path path = Paths.get("C:\\Java_Dev\\test1.txt");

    AclFileAttributeView aclView = Files.getFileAttributeView(path, AclFileAttributeView.class);
    if (aclView == null) {
        System.out.format("ACL view  is not  supported.%n");
        return;// ww  w . j  a  v  a 2  s.  com
    }
    UserPrincipal bRiceUser = FileSystems.getDefault().getUserPrincipalLookupService()
            .lookupPrincipalByName("brice");

    Set<AclEntryPermission> permissions = EnumSet.of(AclEntryPermission.READ_DATA,
            AclEntryPermission.WRITE_DATA);

    AclEntry.Builder builder = AclEntry.newBuilder();
    builder.setPrincipal(bRiceUser);
    builder.setType(AclEntryType.ALLOW);
    builder.setPermissions(permissions);
    AclEntry newEntry = builder.build();

    List<AclEntry> aclEntries = aclView.getAcl();

    aclEntries.add(newEntry);

    aclView.setAcl(aclEntries);
}

From source file:Main.java

public static void awaitThreadState(Thread thread, long maxWaitMillis, Thread.State first,
        Thread.State... rest) {
    EnumSet<Thread.State> set = EnumSet.of(first, rest);
    long deadline = maxWaitMillis + System.currentTimeMillis();
    Thread.State currentState;
    do {/*from   w  w w  .  j a  v a 2 s. c o  m*/
        currentState = thread.getState();
        if (System.currentTimeMillis() > deadline) {
            throw new AssertionError("Timed out waiting for thread state of <" + set + ">: " + thread
                    + " (state = " + thread.getState() + ")");
        }
    } while (!set.contains(currentState));
}

From source file:com.cse.Controller.PermissionHolder.java

public PermissionHolder(PermissionType... permissionArray) {

    permissions = EnumSet.of(PermissionType.EMAIL, permissionArray);
    //email permission is initially required
}

From source file:com.ikanow.aleph2.aleph2_rest_utils.FileUtils.java

public static void writeFile(final FileContext fileContext, final InputStream input, final String path)
        throws AccessControlException, FileAlreadyExistsException, FileNotFoundException,
        ParentNotDirectoryException, UnsupportedFileSystemException, IOException {
    final Path p = new Path(path);
    try (FSDataOutputStream outer = fileContext.create(p, EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE),
            org.apache.hadoop.fs.Options.CreateOpts.createParent())) {
        IOUtils.copyLarge(input, outer, new byte[DEFAULT_BUFFER_SIZE]);
    }/*from w  w w  .ja v  a2  s. c om*/
}

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

protected AbstractDigester(final String keyword, final NodeType first, final NodeType... other) {
    this.keyword = keyword;
    types = EnumSet.of(first, other);
}

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

public SimpleSyntaxChecker(final String keyword, final NodeType type, final NodeType... types) {
    this.keyword = keyword;
    validTypes = EnumSet.of(type, types);
}

From source file:works.bill.web.beans.SpinUpBean.java

public DateThingGroupSet getDatedThings() {
    DateThingGroupSet dateThingGroupSet = new DateThingGroupSet();

    DatedThing thing6 = new DatedThing("Baz", LocalDate.now().minusDays(2), EnumSet.allOf(MyEnum.class));
    DatedThing thing1 = new DatedThing("Foo", LocalDate.now(), EnumSet.allOf(MyEnum.class));
    DatedThing thing5 = new DatedThing("Bar", LocalDate.now(), EnumSet.allOf(MyEnum.class));
    DatedThing thing2 = new DatedThing("Woo", LocalDate.now(), EnumSet.of(MyEnum.FIRST, MyEnum.SECOND));
    DatedThing thing3 = new DatedThing("Yay", LocalDate.now(), EnumSet.of(MyEnum.SECOND, MyEnum.FIRST));
    DatedThing thing4 = new DatedThing("Hoopla", LocalDate.now().plusDays(3), EnumSet.allOf(MyEnum.class));

    dateThingGroupSet.add(thing1);//from  w  w w . j  a v  a 2 s . c  o m
    dateThingGroupSet.add(thing2);
    dateThingGroupSet.add(thing3);
    dateThingGroupSet.add(thing4);
    dateThingGroupSet.add(thing5);
    dateThingGroupSet.add(thing6);

    return dateThingGroupSet;
}

From source file:ch.cyberduck.core.manta.MantaAccountHomeInfo.java

public MantaAccountHomeInfo(final String username, final String defaultPath) {
    final String[] accountPathParts = MantaUtils.parseAccount(username);

    accountRoot = new Path(accountPathParts[0], EnumSet.of(Path.Type.directory, Path.Type.placeholder));
    accountOwner = accountRoot.getName();
    normalizedHomePath = this.buildNormalizedHomePath(defaultPath);

    accountPublicRoot = new Path(accountRoot, HOME_PATH_PUBLIC,
            EnumSet.of(Path.Type.volume, Path.Type.directory));
    accountPrivateRoot = new Path(accountRoot, HOME_PATH_PRIVATE,
            EnumSet.of(Path.Type.volume, Path.Type.directory));
}