多个枚举 - 通过另一个枚举值获取枚举类型

时间:2021-01-11 15:32:06

标签: java spring enums generic-programming

考虑我有多个枚举,每个枚举都有不同的值,但都与相似的事情有关:

wrapper = query_kw(uri)
res_keys = process(palabra)
for k in rest_keys.keys():
    wrap = {'keyword': rest_keys[k], 'language': rest_keys[k]['language']
    for ind in wrapper:
        for key, value in wrapper[ind]:
            for ky, v in wrap:  
                if key is not ky and value is not v:
                    wrapper.append(wrap)

现在我有了一个方法:

@Getter
@RequiredArgsConstructor
public enum Dict implements Dictionary {

    VALUE1 ("Value1"),
    VALUE2 ("Value2");

    private final String name;
}

@Getter
@RequiredArgsConstructor
public enum Dict2 implements Dictionary {

    VALUE3 ("Value3"),
    VALUE4 ("Value4");

    private final String name;
}

...

Dict3 implements Dictionary{}
Dict4 implements Dictionary{}
Dict5 implements Dictionary{}

etc.

有没有一种很好的方法可以通过方法中提供的 Enum 获取特定的 Dictionary 类型?希望我已经说清楚了。

0 个答案:

没有答案