首先,如果这是现有问题的副本,请道歉.不确定如何说出我的问题,这可能就是为什么我还没有找到一个明确的答案.基本上,我想知道以下是否被视为良好做法或是否有更好的方法来做到这一点:
public enum ExampleEnum {
ENTRY_1(new ExampleCodedValue("entry1", "comment1")),
ENTRY_2(new ExampleCodedValue("entry2", "comment2")),
ENTRY_3(new ExampleCodedValue("entry3", "comment3")),
ENTRY_4(new ExampleCodedValue("entry4", "comment4"));
private ExampleCodedValue codedValue;
ExampleEnum(ExampleCodedValue codedValue) {
this.codedValue = codedValue;
}
public ExampleCodedValue getCodedValue() {
return codedValue;
}
}
class ExampleCodedValue {
private final String code;
private final String comment;
ExampleCodedValue(String code, String comment) {
this.code = code;
this.comment = comment;
}
}