Why not just use a constructor, for example:
public enum RuleItem {
MORE_THAN(1, "rulesName.moreThan"),
LESS_THAN(2, "rulesName.lessThan"),
MORE_OR_EQUAL(3, "rulesName.moreOrEqual");
private int value;
private String representation;
private RuleItem(int value, String representation) {
this.value = value;
this.representation = representation;
}
public String getStringRepresentation() {
return representation;
}
}
Then you can add as many arguments and methods as you want, but without overriding them personally for each value (just pass it in the constructor).
source
share