A DESCRIPTION OF THE REQUEST :
java.lang.Enum should have a static method values(Class<T>).
The signature of the method would be that:
public static <T extends Enum<T>> T[] values(Class<T> enumType);
JUSTIFICATION :
Every enum class has a static method valueOf(String) which the compiler generates in subclasses. The java.lang.Enum has the static method valueOf(Class<T>, String) which is a "companion" of the valueOf(String). The method valueOf(Class<T>, String) is very helpful in enum-based data structures.
However, the values() method doesn't have a "companion" in java.lang.Enum. This makes a defficiency when working in enum-based data structures which the method values(Class<T>) could easily supply.
java.lang.Enum should have a static method values(Class<T>).
The signature of the method would be that:
public static <T extends Enum<T>> T[] values(Class<T> enumType);
JUSTIFICATION :
Every enum class has a static method valueOf(String) which the compiler generates in subclasses. The java.lang.Enum has the static method valueOf(Class<T>, String) which is a "companion" of the valueOf(String). The method valueOf(Class<T>, String) is very helpful in enum-based data structures.
However, the values() method doesn't have a "companion" in java.lang.Enum. This makes a defficiency when working in enum-based data structures which the method values(Class<T>) could easily supply.
- relates to
-
JDK-8073381 need API to get enum's values without creating a new array
-
- Open
-
-
JDK-6436941 (enum) add method getEnumConstant(int i) to java.lang.Class
-
- Closed
-