Package discord4j.core.object.util
Class PermissionSet
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<Permission>
-
- discord4j.core.object.util.PermissionSet
-
- All Implemented Interfaces:
Iterable<Permission>
,Collection<Permission>
,Set<Permission>
public final class PermissionSet extends AbstractSet<Permission>
An immutable specializedSet
implementation for use with thePermission
type.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PermissionSet
all()
Returns aPermissionSet
containing all permissions.PermissionSet
and(PermissionSet other)
Performs a logical AND of of this permission set with the other permission set.EnumSet<Permission>
asEnumSet()
Gets thisPermissionSet
as anEnumSet
.boolean
contains(Object o)
long
getRawValue()
Gets the raw value for thisPermissionSet
.Iterator<Permission>
iterator()
static PermissionSet
none()
Returns aPermissionSet
containing no permissions.PermissionSet
not()
Performs a logical NOT of this permission set.static PermissionSet
of(long rawValue)
Returns aPermissionSet
containing all the permissions represented by the raw value.static PermissionSet
of(Permission... permissions)
Returns aPermissionSet
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)
Subtracts the contents of the given permission set from this permission set.String
toString()
PermissionSet
xor(PermissionSet other)
Performs a logical XOR of this permission set with the other permission set.-
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
-
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
-
-
-
Method Detail
-
all
public static PermissionSet all()
Returns aPermissionSet
containing all permissions.- Returns:
- A
PermissionSet
containing all permissions.
-
none
public static PermissionSet none()
Returns aPermissionSet
containing no permissions.- Returns:
- A
PermissionSet
containing no permissions.
-
of
public static PermissionSet of(long rawValue)
Returns aPermissionSet
containing all the permissions represented by the raw value.- Parameters:
rawValue
- A bit-wise OR evaluation of multiple values returned byPermission.getValue()
.- Returns:
- A
PermissionSet
containing all the permissions represented by the raw value.
-
of
public static PermissionSet of(Permission... permissions)
Returns aPermissionSet
containing all the supplied permissions.- Parameters:
permissions
- The permissions to add to thePermissionSet
.- Returns:
- A
PermissionSet
containing all the supplied permissions.
-
and
public PermissionSet and(PermissionSet other)
Performs a logical AND of of this permission set with the other permission set.- Parameters:
other
- The other permission set.- Returns:
- A new permission set of this set AND the other set.
-
or
public PermissionSet or(PermissionSet other)
Performs a logical OR of this permission set with the other permission set.- Parameters:
other
- The other permission set.- Returns:
- A new permission set of this set OR the other set.
-
not
public PermissionSet not()
Performs a logical NOT of this permission set.- Returns:
- A new permission set representing this set's complement.
-
xor
public PermissionSet xor(PermissionSet other)
Performs a logical XOR of this permission set with the other permission set.- Parameters:
other
- The other permission set.- Returns:
- A new permission set of this set XOR the other set.
-
subtract
public PermissionSet subtract(PermissionSet other)
Subtracts the contents of the given permission set from this permission set.- Parameters:
other
- The other permission set.- Returns:
- A new permission set with the contents of the other set removed.
-
asEnumSet
public EnumSet<Permission> asEnumSet()
Gets thisPermissionSet
as anEnumSet
.- Returns:
- This
PermissionSet
as anEnumSet
.
-
getRawValue
public long getRawValue()
Gets the raw value for thisPermissionSet
.- Returns:
- The raw value for this
PermissionSet
. - See Also:
PermissionSet
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<Permission>
- Specified by:
contains
in interfaceSet<Permission>
- Overrides:
contains
in classAbstractCollection<Permission>
-
iterator
public Iterator<Permission> iterator()
- Specified by:
iterator
in interfaceCollection<Permission>
- Specified by:
iterator
in interfaceIterable<Permission>
- Specified by:
iterator
in interfaceSet<Permission>
- Specified by:
iterator
in classAbstractCollection<Permission>
-
size
public int size()
- Specified by:
size
in interfaceCollection<Permission>
- Specified by:
size
in interfaceSet<Permission>
- Specified by:
size
in classAbstractCollection<Permission>
-
toString
public String toString()
- Overrides:
toString
in classAbstractCollection<Permission>
-
-