Class EnumUtil


  • public final class EnumUtil
    extends Object
    Utility class for accessing Java enum types.
    • Method Detail

      • names

        public static <T extends Enum<T>> Set<String> names​(Class<T> enumType)
        Returns a set of the names of the enum constants of the specified enum type. The returned set maintains iteration order of the constants in the order they're declared in the enum type.
        Type Parameters:
        T - enumeration type
        Parameters:
        enumType - the class of the enum type from which to return the names.
        Returns:
        a set of the names of the enum constants in the specified enum.
      • valueOf

        public static <T extends Enum<T>> T valueOf​(Class<T> enumType,
                                                    Object name)
        Returns the enum constant of the specified enum type with the specified name.
        Type Parameters:
        T - enumeration type
        Parameters:
        enumType - The class of the enum type from which to return a constant.
        name - The name of the constant to return.
        Returns:
        The matching enum constant or IllegalArgumentException if no match found.
        Throws:
        IllegalArgumentException - if no match found.