public final class PermissionSet extends AbstractSet<Permission>
Set<Permission>.
This is a value-based
class; use of identity-sensitive operations (including reference equality
(==), identity hash code, or synchronization) on instances of
PermissionSet may have unpredictable results and should be avoided.
The equals method should be used for comparisons.
| Modifier and Type | Method and Description |
|---|---|
static PermissionSet |
all()
Returns a
PermissionSet containing all permissions. |
PermissionSet |
and(PermissionSet other)
Performs a logical AND of this permission set with the other permission set.
|
PermissionSet |
andNot(PermissionSet other)
Performs a logical AND NOT of this permission set with the other permission set.
|
EnumSet<Permission> |
asEnumSet()
Gets this
PermissionSet as an EnumSet. |
boolean |
contains(Object o) |
boolean |
equals(Object o) |
long |
getRawValue()
Gets the raw value for this
PermissionSet. |
int |
hashCode() |
Iterator<Permission> |
iterator() |
static PermissionSet |
none()
Returns a
PermissionSet containing no permissions. |
PermissionSet |
not()
Performs a logical NOT of this permission set.
|
static PermissionSet |
of(long rawValue)
Returns a
PermissionSet containing all the permissions represented by the raw value. |
static PermissionSet |
of(Permission... permissions)
Returns a
PermissionSet containing all the supplied permissions. |
PermissionSet |
or(PermissionSet other)
Performs a logical OR of this permission set with the other permission set.
|
int |
size() |
PermissionSet |
subtract(PermissionSet other)
Deprecated.
Use
andNot(PermissionSet) instead. |
String |
toString() |
PermissionSet |
xor(PermissionSet other)
Performs a logical XOR of this permission set with the other permission set.
|
removeAlladd, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitadd, addAll, clear, containsAll, isEmpty, remove, retainAll, spliterator, toArray, toArrayparallelStream, removeIf, streampublic static PermissionSet all()
PermissionSet containing all permissions.PermissionSet containing all permissions.public static PermissionSet none()
PermissionSet containing no permissions.PermissionSet containing no permissions.public static PermissionSet of(long rawValue)
PermissionSet containing all the permissions represented by the raw value.rawValue - A bit-wise OR evaluation of multiple values returned by Permission.getValue().PermissionSet containing all the permissions represented by the raw value.public static PermissionSet of(Permission... permissions)
PermissionSet containing all the supplied permissions.permissions - The permissions to add to the PermissionSet.PermissionSet containing all the supplied permissions.public PermissionSet and(PermissionSet other)
The resultant set is the intersection of this set and the other set. A permission is contained if and only if it was
contained in both this set and the other set. This is analogous to Set.retainAll(java.util.Collection).
PermissionSet set0 = PermissionSet.of(KICK_MEMBERS, BAN_MEMBERS);
PermissionSet set1 = PermissionSet.of(KICK_MEMBERS);
set0.and(set1) = PermissionSet.of(KICK_MEMBERS)
other - The other permission set.public PermissionSet or(PermissionSet other)
The resultant set is the union of this set and the other set. A permission is contained if and only if it
was contained in either this set or the other set. This is analogous to Set.addAll(java.util.Collection).
PermissionSet set0 = PermissionSet.of(KICK_MEMBERS);
PermissionSet set1 = PermissionSet.of(BAN_MEMBERS);
set0.or(set1) = PermissionSet.of(KICK_MEMBERS, BAN_MEMBERS)
other - The other permission set.public PermissionSet xor(PermissionSet other)
The resultant set is the symmetric difference of this set and the other set. A permission is contained if and only if it was contained in only this set or contained in only the other set.
PermissionSet set0 = PermissionSet.of(KICK_MEMBERS, BAN_MEMBERS, ATTACH_FILES);
PermissionSet set1 = PermissionSet.of(ATTACH_FILES, CONNECT);
set0.xor(set1) = PermissionSet.of(KICK_MEMBERS, BAN_MEMBERS, CONNECT)
other - The other permission set.public PermissionSet andNot(PermissionSet other)
The resultant set is the relative complement of this set and the other set. A permission is contained if
and only if it was contained in this set and not contained in the other set. This is analogous to
Set.removeAll(java.util.Collection).
PermissionSet set0 = PermissionSet.of(KICK_MEMBERS, BAN_MEMBERS, ATTACH_FILES);
PermissionSet set1 = PermissionSet.of(BAN_MEMBERS, ATTACH_FILES, CONNECT);
set0.andNot(set1) = PermissionSet.of(KICK_MEMBERS)
other - The other permission set.@Deprecated public PermissionSet subtract(PermissionSet other)
andNot(PermissionSet) instead.The resultant set is the relative complement of this set and the other set. A permission is contained if and only if it was contained in this set and not contained in the other set.
PermissionSet set0 = PermissionSet.of(KICK_MEMBERS, BAN_MEMBERS, ATTACH_FILES);
PermissionSet set1 = PermissionSet.of(BAN_MEMBERS, ATTACH_FILES, CONNECT);
set0.subtract(set1) = PermissionSet.of(KICK_MEMBERS)
other - The other permission set.public PermissionSet not()
The resultant set is the complement of this set. A permission is contained if and only if it was not contained in this set.
PermissionSet set = PermissionSet.none();
set.not() = PermissionSet.all()
public EnumSet<Permission> asEnumSet()
PermissionSet as an EnumSet.PermissionSet as an EnumSet.public long getRawValue()
PermissionSet.PermissionSet.PermissionSetpublic boolean contains(Object o)
contains in interface Collection<Permission>contains in interface Set<Permission>contains in class AbstractCollection<Permission>public Iterator<Permission> iterator()
iterator in interface Iterable<Permission>iterator in interface Collection<Permission>iterator in interface Set<Permission>iterator in class AbstractCollection<Permission>public int size()
size in interface Collection<Permission>size in interface Set<Permission>size in class AbstractCollection<Permission>public boolean equals(Object o)
equals in interface Collection<Permission>equals in interface Set<Permission>equals in class AbstractSet<Permission>public int hashCode()
hashCode in interface Collection<Permission>hashCode in interface Set<Permission>hashCode in class AbstractSet<Permission>public String toString()
toString in class AbstractCollection<Permission>