Java EnumSet Create of(E[] c)

Here you can find the source of of(E[] c)

Description

of

License

Apache License

Declaration

public static <E extends Enum<E>> EnumSet<E> of(E[] c) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.EnumSet;

public class Main {
    public static <E extends Enum<E>> EnumSet<E> of(E[] c) {
        if (c.length == 0) {
            throw new IllegalArgumentException("Collection is empty");
        }/*from ww  w  .  j  av a 2  s . com*/

        EnumSet<E> result = EnumSet.of(c[0]);
        if (c.length > 1) {
            for (int i = 1; i < c.length; i++) {
                result.add(c[i]);
            }
        }
        return result;
    }
}

Related

  1. fromString(Class enumClass, String name)
  2. intToEnumSet(Class enumClass, int decoded)
  3. newEnumSet(Class klass)
  4. noneOf( Class elementType)
  5. of(E e1, E... e)
  6. parseEnum(final Class klass, final String input)
  7. toEnumSet( Class classValue, Collection stringValues)
  8. toEnumSet(Class enumClass, long vector)
  9. toEnumSet(Class clazz, T... ts)