enum class A
の列挙型定数がサブenum class B
を関連付けenum class C
、独自の定数を含むシナリオを作成しようとしています。の定数enum class B
とenum class C
からの定数のサブセットをグループ化しenum class D
ます。以下は基本的に私が達成しようとしていることです:
enum A {
CONST_1 ("const_1", B), // B is the associated enum
CONST_2 ("const_2", C); // C in the associated enum
private final String strVal;
private final Enum associatedEnum;
private A (String strVal, Enum associatedEnum) {
this.strVal = strVal;
this.associatedEnum = associatedEnum;
}
public Enum getAssociatedEnum() {
return this.associatedEnum;
}
public String toString() {
return this.strVal;
}
// Associated Enum contained subset of grouped constants
enum B {
CONST_3 (D.CONST_7.toString()),
CONST_4 (D.CONST_8.toString());
private final String strVal;
private B (String strVal) {
this.strVal = strVal;
}
public String toString() {
return this.strVal;
}
}
// Associated Enum contained subset of grouped constants
enum C {
CONST_5 (D.CONST_9.toString()),
CONST_6 (D.CONST_10.toString());
private final String strVal;
private C (String strVal) {
this.strVal = strVal;
}
public String toString() {
return this.strVal;
}
}
}
// Separate Enum containing all ungrouped constants
enum D {
CONST_7 ("const_7"),
CONST_8 ("const_8");
CONST_9 ("const_9"),
CONST_10 ("const_10");
private final String strVal;
private D (String strVal) {
this.strVal = strVal;
}
public String toString() {
return this.strVal;
}
}
この方法ではJavaでクラスを渡すことができないため、明らかにこの構文はOOTBでは機能しません。しかし、誰かが私がこれを達成できる方法を提案できますか?
これを使用して、クライアント側アプリケーションの静的構造化グループを検証したいと考えています。