List of Java Transitions from the Class

How do I go from an object Classto a list of listings in general?

i.e.

public static <T extends Enum> List<T> getList(Class<T> clazz)

I can not find a way to get to the method values()

+3
source share
1 answer

Class#getEnumConstants() returns enum constants (safe type).

So,

public static <T extends Enum> List<T> getList(Class<T> clazz) {
    return Arrays.asList(clazz.getEnumConstants());
}
+14
source

Source: https://habr.com/ru/post/1745793/


All Articles