Why can't we parameterize enum types? Is there a reason for the restriction?
I would find it natural to do something like the following:
public enum EnumType<T> {
val1,val2,val3;
private T attribute = null;
public T getAttribute() { return attribute; }
public void setAttribute(T t) { attribute = t; }
}
EnumType<List<String>> ref = EnumType<List<String>>.val2;
List<String> list = new LinkedList<String>();
... fill list ...
ref.setAttribute(list);
If I understand the enum proposal correctly then the enum type is basically a class that extends superclass Enum. Why can't that class be parameterized? Is there a technical reason for this restriction?
BTW, I would find it helpful if the enum spec mentioned that a nested enum type is implicitly static. Just for clarity; it aids understanding of certain error messages where the compiler talks of "static context".
class Outer {
public enum Inner { ... } // <<< this is a static nested type although I did not say so
}