How do I go from a Class
object to a list of enums generically?
i.e.
public static <T extends Enum> List<T> getList(Class<T> clazz)
I cant find a way to get to the values()
method
How do I go from a Class
object to a list of enums generically?
i.e.
public static <T extends Enum> List<T> getList(Class<T> clazz)
I cant find a way to get to the values()
method
Class#getEnumConstants()
returns the enum constants (type-safe).
So,
public static <T extends Enum> List<T> getList(Class<T> clazz) {
return Arrays.asList(clazz.getEnumConstants());
}