Instead, use the available API:
T[] getValuesForEnum(Class<T> type) { return type.getEnumConstants(); }
From Javadoc :
Returns the elements of this class enum or null if this class object does not represent an enumeration type.
Please note that I turned your method into a generic one to make it typafe. This way you don't need descending ones to get the actual enum values from the returned array. (Of course, this makes the method so trivial that you can omit it and directly call type.getEnumConstants()
source share