I have multiple enum types, a typical implementation is as follows.
public enum SomeType {
TYPE_A("aaa"),
TYPE_B("bbb"),
private final String type;
private SomeType(String type) { this.type = type; }
public boolean equals(String otherType) {
return (otherType == null) ? false : type.equals(otherType.toUpperCase());
}
}
Other than specific enum types, the constructor and methods (i.e., equals and a few more) are the same for these enums. I cant create a super "class" and extends from it. Is there a clean solution so that I only need 1 copy of these methods and make all enum types inherit them? Thanks.