Class IntentSet
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<Intent>
-
- discord4j.gateway.intent.IntentSet
-
public final class IntentSet extends AbstractSet<Intent>
An immutable, specializedSet<Intent>
.This is a value-based class; use of identity-sensitive operations (including reference equality (
==
), identity hash code, or synchronization) on instances ofIntentSet
may have unpredictable results and should be avoided. Theequals
method should be used for comparisons.- See Also:
- Discord Intents
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static IntentSet
all()
Returns aIntentSet
containing all intents.IntentSet
and(IntentSet other)
Performs a logical AND of this intent set with the other intent set.IntentSet
andNot(IntentSet other)
Performs a logical AND NOT of this intent set with the other intent set.EnumSet<Intent>
asEnumSet()
Gets thisIntentSet
as anEnumSet
.boolean
contains(Object o)
boolean
equals(Object o)
long
getRawValue()
Gets the raw value for thisIntentSet
.int
hashCode()
Iterator<Intent>
iterator()
static IntentSet
none()
Returns aIntentSet
containing no intents.static IntentSet
nonPrivileged()
Returns aIntentSet
containing non-privileged intents.IntentSet
not()
Performs a logical NOT of this intent set.static IntentSet
of(long rawValue)
Returns aIntentSet
containing all the intents represented by the raw value.static IntentSet
of(Intent... intents)
Returns aIntentSet
containing all the supplied intents.IntentSet
or(IntentSet other)
Performs a logical OR of this intent set with the other intent set.int
size()
String
toString()
IntentSet
xor(IntentSet other)
Performs a logical XOR of this intent set with the other intent set.-
Methods inherited from class java.util.AbstractSet
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 IntentSet all()
Returns aIntentSet
containing all intents.- Returns:
- A
IntentSet
containing all intents.
-
none
public static IntentSet none()
Returns aIntentSet
containing no intents.- Returns:
- A
IntentSet
containing no intents.
-
nonPrivileged
public static IntentSet nonPrivileged()
Returns aIntentSet
containing non-privileged intents.- Returns:
- A
IntentSet
containing non-privileged intents. - See Also:
- Privileged Intents
-
of
public static IntentSet of(long rawValue)
Returns aIntentSet
containing all the intents represented by the raw value.- Parameters:
rawValue
- A bit-wise OR evaluation of multiple values returned byIntent.getValue()
.- Returns:
- A
IntentSet
containing all the intents represented by the raw value.
-
of
public static IntentSet of(Intent... intents)
Returns aIntentSet
containing all the supplied intents.- Parameters:
intents
- The intents to add to theIntentSet
.- Returns:
- A
IntentSet
containing all the supplied intents.
-
and
public IntentSet and(IntentSet other)
Performs a logical AND of this intent set with the other intent set.The resultant set is the intersection of this set and the other set. A intent 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)
.IntentSet set0 = IntentSet.of(GUILDS, GUILD_MEMBERS); IntentSet set1 = IntentSet.of(GUILDS); set0.and(set1) = IntentSet.of(GUILDS)
- Parameters:
other
- The other intent set.- Returns:
- The intersection of this set with the other set.
-
or
public IntentSet or(IntentSet other)
Performs a logical OR of this intent set with the other intent set.The resultant set is the union of this set and the other set. A intent 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)
.IntentSet set0 = IntentSet.of(GUILDS); IntentSet set1 = IntentSet.of(GUILD_MEMBERS); set0.or(set1) = IntentSet.of(GUILDS, GUILD_MEMBERS)
- Parameters:
other
- The other intent set.- Returns:
- The union of this set with the other set.
-
xor
public IntentSet xor(IntentSet other)
Performs a logical XOR of this intent set with the other intent set.The resultant set is the symmetric difference of this set and the other set. A intent is contained if and only if it was contained in only this set or contained in only the other set.
IntentSet set0 = IntentSet.of(GUILDS, GUILD_MEMBERS, GUILD_BANS); IntentSet set1 = IntentSet.of(GUILD_BANS, GUILD_EMOJIS); set0.xor(set1) = IntentSet.of(GUILDS, GUILD_MEMBERS, GUILD_EMOJIS)
- Parameters:
other
- The other intent set.- Returns:
- The symmetric difference of this set with the other set.
-
andNot
public IntentSet andNot(IntentSet other)
Performs a logical AND NOT of this intent set with the other intent set.The resultant set is the relative complement of this set and the other set. A intent 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)
.IntentSet set0 = IntentSet.of(GUILDS, GUILD_MEMBERS, GUILD_BANS); IntentSet set1 = IntentSet.of(GUILD_MEMBERS, GUILD_BANS, GUILD_EMOJIS); set0.andNot(set1) = IntentSet.of(GUILDS)
- Parameters:
other
- The other intent set.- Returns:
- The relative complement of this set with the other set.
-
not
public IntentSet not()
Performs a logical NOT of this intent set.The resultant set is the complement of this set. A intent is contained if and only if it was not contained in this set.
IntentSet set = IntentSet.none(); set.not() = IntentSet.all()
- Returns:
- The complement of this set.
-
asEnumSet
public EnumSet<Intent> asEnumSet()
Gets thisIntentSet
as anEnumSet
.- Returns:
- This
IntentSet
as anEnumSet
.
-
getRawValue
public long getRawValue()
Gets the raw value for thisIntentSet
.- Returns:
- The raw value for this
IntentSet
. - See Also:
IntentSet
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<Intent>
- Specified by:
contains
in interfaceSet<Intent>
- Overrides:
contains
in classAbstractCollection<Intent>
-
size
public int size()
- Specified by:
size
in interfaceCollection<Intent>
- Specified by:
size
in interfaceSet<Intent>
- Specified by:
size
in classAbstractCollection<Intent>
-
equals
public boolean equals(@Nullable Object o)
- Specified by:
equals
in interfaceCollection<Intent>
- Specified by:
equals
in interfaceSet<Intent>
- Overrides:
equals
in classAbstractSet<Intent>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<Intent>
- Specified by:
hashCode
in interfaceSet<Intent>
- Overrides:
hashCode
in classAbstractSet<Intent>
-
toString
public String toString()
- Overrides:
toString
in classAbstractCollection<Intent>
-
-