A DESCRIPTION OF THE REQUEST :
Allow the declaration of "abstract enum" classes where the implementation of the "enum" class is implemented. Specifying values in the "abstract enum" should be disallowed.
The "actual" enum class could extend the "abstract enum" class and add the declaration of the enum values.
JUSTIFICATION :
The usefullness of the fact that enums are just classes is very limited by the fact that the complete implementation _must_ reside in the enum class itself.
It is currently not possible to make different enums share the same implementation. If I have multiple enum classes that differ only in enum values but have the same implementation I must copy the implementation code in all enum classes. Not very maintainable!
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
This should compile:
abstract enum MyEnumImpl {
private int value;
MyEnumImpl(int value) {
this.value = value;
}
public int getValue() { return value; }
}
enum MyEnum extends MyEnumImpl {
ONE(1),
TWO(2)
}
ACTUAL -
"abstract enum MyAbstractEnum" is disallowed
"enum MyEnum extends MyAbstracEnum" is disallowed
CUSTOMER SUBMITTED WORKAROUND :
Copy the implementation code in every enum class
###@###.### 2005-1-27 09:43:04 GMT