I have an enum :
public enum PermissionsEnum {
ABC("Abc"),
XYZ("Xyz"),
....
}
And then I have a list of Enums. I want to check if my list has at least one of the enums. I currently check it by an iterative approach. I also know there is a way to do it by using ||
checking list.contains(enum.ABC..) || list.contains(enum.XYZ) || ...
.
Is there a better way to do it?
This question shows how to do it if the objective list is a list of Strings, I want to get the matching status if the list is another list of enums.
!Collections.disjoint(list1, list2);
to check if list2 contains elements form list2List<PermissionEnum>
, aren't all elements one of those enums? Aside from that, the best way to store a collection of enums is in anEnumSet
, because it doesn't make sense to have the same permission twice or more.