まず、これが既存の質問の重複である場合はお詫び申し上げます。質問の言い方が正確にわからなかったので、まだ明確な答えが見つからなかったのかもしれません。基本的に、次のことが良い習慣と見なされるかどうか、またはこれを行うためのより良い方法があるかどうかを知りたいです。
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;
}
}