If I understand correctly what you want to do, it is something like this:
public abstract class DatabaseField { private String fieldName; private DatabaseField(String fieldName) { this.fieldName = fieldName; } public String getFieldName() { return fieldName; } }
Then define your enum to extend this class. However, unfortunately, an enumeration cannot extend the class, but it can implement an interface, so the best thing at the moment is to define an interface that includes the getFieldName () method, and all your enums implement this interface.
However, this means that you will have to duplicate the implementation of this method (and any others) in all of your enumerations. There are several suggestions in this question about ways to minimize this duplication.
Dónal
source share