我想在参数中限制特定类型的枚举常量。
例如,
enum SomeEnum { A, B, C}
class SomeClass {
public void doSomething(SomeEnum someEnum) { <--- Here I want to only accept A and C.
}
}
当呼叫者输入代码时,
SomeClass someclass = new SomeClass();
someclass.doSomething(); <------- java assist would say only A and C goes in here
答案 0 :(得分:-1)
将一个枚举值集添加到某个类的硬编码或构造函数中。