The list of methods to do EnumSet Usage are organized into topic(s).
void
awaitThreadState(Thread thread, long maxWaitMillis, Thread.State first, Thread.State... rest) await Thread State
EnumSet<Thread.State> set = EnumSet.of(first, rest);
long deadline = maxWaitMillis + System.currentTimeMillis();
Thread.State currentState;
do {
currentState = thread.getState();
if (System.currentTimeMillis() > deadline) {
throw new AssertionError("Timed out waiting for thread state of <" + set + ">: " + thread
+ " (state = " + thread.getState() + ")");
...
int
encode(EnumSet set) encode
int ret = 0;
for (E val : set) {
ret |= 1 << val.ordinal();
return ret;
List
> extractTypes(final Class type)
A convenient method for extracting type information from all enum value for a specified enum type.
final List<Class<?>> result = new ArrayList<>();
result.add(type);
final EnumSet<E> mnemonicEnumSet = EnumSet.allOf(type);
for (final E value : mnemonicEnumSet) {
result.add(value.getClass());
return result;
HashMap
getDataFromEnum(Class enumClass)
This method return all enums in class.
HashMap<String, String> enumValues = new HashMap<String, String>();
for (E enumField : EnumSet.allOf(enumClass)) {
String key = enumField.name();
String value = enumField.toString();
enumValues.put(key, value);
return enumValues;
HashMap
getDataInEnumClass(String enumClassName)
get Data In Enum Class
try {
@SuppressWarnings("rawtypes")
Class clazz = Class.forName(enumClassName);
if (clazz.isEnum()) {
return getDataFromEnum(clazz);
} catch (ClassNotFoundException e) {
return new HashMap<String, String>();
Enum
getEnumFromString(Class enumClass, String enumValue, boolean compareByValue)
This method return Enum which name values is equals to String, which is given as parameter.
if (enumClass == null || enumValue == null || enumValue.isEmpty()) {
throw new IllegalArgumentException(
"Class shouldn't be null and value to compare shouldn't be null or empty.");
for (E enumField : EnumSet.allOf(enumClass)) {
if (compareByValue) {
if (enumField.toString().equalsIgnoreCase(enumValue)) {
return enumField;
...
List>
nativeLoadEnumDefaultValues(Class enumType) native Load Enum Default Values
List<?> result = null;
EnumSet values = (enumType != null ? EnumSet.allOf(enumType) : null);
if (values != null) {
result = new ArrayList();
result.addAll(values);
return result;