具有逻辑或选择的 Java ENUM
我想实现一种方法,返回一个或一组定义为枚举的允许操作。
例如我的方法应该是这样的:
public enum getAllowedActions() {
return // (( 'something like' Actions.ACTION1 & Actions.ACTION2 ));
}
然后在另一个位置读取结果,例如:
if (getAllowedActions() == Actions.ACTION1) {
// do something...
}
with:
public class enum {
ACTION1, ACTION2;
}
谢谢。 斯特凡诺.
I would like to implement a method that returns one or a list of allowed Action defined as enum.
For example my method should be like this:
public enum getAllowedActions() {
return // (( 'something like' Actions.ACTION1 & Actions.ACTION2 ));
}
and then read the results in another position like:
if (getAllowedActions() == Actions.ACTION1) {
// do something...
}
with:
public class enum {
ACTION1, ACTION2;
}
Thanks.
Stefano.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您只是在寻找
EnumSet
:Sounds like you're just lookng for
EnumSet
: