Assuming I have a basic enum like:
public enum Color { Red, Green, Blue}
How to write one generic class that only accepts “enum classes” so that a particular instance of this generic class would look like MyClass<Color>
?
Edit:
What you really need to do is write a generic abstract class containing a function that returns all enumerations of the "record" in a list:
public abstract class EnumListBean<E extends Enum<E>> { public List<E> getEnumList() { return Arrays.asList(E.values()); } }
While Day.values()
is available E.values()
not. What am I doing wrong here?
source share