I'm trying to write a generic method for initializing an EnumSet value from an integer containing a bit mask. I'm getting a compiler error I don't understand. Here's my code:
private <E extends Enum<E>> void setEnumSet( EnumSet<E> es, int iEnum ) {
es.clear();
for (E e : E.values()) {
if (0 != (iEnum & (1<<e.ordinal()))) {
es.add(e);
}
}
}
Compiler error:
1>Javac...
1>.\wdqapi.java:266: error: cannot find symbol
1> for (E e : E.values()) {
1> ^
1> symbol: method values()
1> location: class Enum<E>
1> where E is a type-variable:
1> E extends Enum<E> declared in method <E>_setEnumSet(EnumSet<E>,int)
Is there some special syntax for accessing the values() method of E? (I'm a Java noob.) Can someone help me past this compiler error? Thanks.