Java EnumSet Usage extractTypes(final Class type)

Here you can find the source of extractTypes(final Class type)

Description

A convenient method for extracting type information from all enum value for a specified enum type.

License

Open Source License

Parameter

Parameter Description
E a parameter
type a parameter

Declaration

public static <E extends Enum<E>> List<Class<?>> extractTypes(final Class<E> type) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.EnumSet;

import java.util.List;

public class Main {
    /**//w ww . j  a  v  a  2s .  com
     * A convenient method for extracting type information from all enum value for a specified enum type.
     *
     * @param <E>
     * @param type
     * @return
     */
    public static <E extends Enum<E>> List<Class<?>> extractTypes(final Class<E> 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;
    }
}

Related

  1. awaitThreadState(Thread thread, long maxWaitMillis, Thread.State first, Thread.State... rest)
  2. copyOf(Collection src, Class type)
  3. deepCloneEnumSet(final EnumSet set)
  4. encode(EnumSet set)
  5. findEnumIgnoreCase(Class enumClass, String string, T defValue)
  6. getDataFromEnum(Class enumClass)
  7. getDataInEnumClass(String enumClassName)
  8. getEnumFromString(Class enumClass, String enumValue, boolean compareByValue)