List of utility methods to do EnumSet Create
EnumSet | asSet(E[] array) as Set return array != null ? asSet(Arrays.asList(array)) : null;
|
EnumSet | createEnumSet(Class create Enum Set if (elementType == null) { return null; return EnumSet.allOf(elementType); |
E | enumFromSet(EnumSet enum From Set if (theSet.isEmpty()) { return null; } else { return theSet.iterator().next(); |
EnumSet | enumSet(T... elements) Terse (especially as a static import) way to create an EnumSet. return EnumSet.<T>of(elements[0], elements);
|
EnumSet | enumSetOf(long bitSet, Class enum Set Of if (bitSet == EMPTY_BIT_SET) { return EnumSet.noneOf(eClass); EnumSet<E> flagSet = EnumSet.noneOf(eClass); for (E f : eClass.getEnumConstants()) { if (hasEnum(bitSet, f)) { flagSet.add(f); return flagSet; |
Set | fromString(Class from String final Set<E> enumValues = new HashSet<E>(); final StringTokenizer tokens = value == null ? null : new StringTokenizer(value); if (tokens == null || !tokens.hasMoreTokens()) { return EnumSet.noneOf(enumType); for (; tokens.hasMoreTokens();) { try { final E enumValue = Enum.valueOf(enumType, tokens.nextToken()); ... |
T | fromString(Class Parses an Enum of type T case insensitively. if (name == null) { return null; EnumSet<T> values = EnumSet.allOf(enumClass); for (T value : values) { if (value.name().equalsIgnoreCase(name)) { return value; int index = Integer.parseInt(name); if (index < values.size() && index >= 0) { return (T) values.toArray()[index]; throw new IllegalArgumentException("No enum constant " + enumClass.getCanonicalName() + "." + name); |
EnumSet | intToEnumSet(Class Get an enum set by parsing an integer which represents a bit array. EnumSet<T> enumSet = EnumSet.noneOf(enumClass); T[] enums = enumClass.getEnumConstants(); while (decoded != 0) { int ordinal = Integer.numberOfTrailingZeros(decoded); enumSet.add(enums[ordinal]); decoded -= Integer.lowestOneBit(decoded); return enumSet; ... |
EnumSet | newEnumSet(Class new Enum Set return EnumSet.noneOf(klass);
|
EnumSet | noneOf(Class none Of return EnumSet.noneOf(elementType);
|