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 ofIntentSetmay have unpredictable results and should be avoided. Theequalsmethod 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 IntentSetall()Returns aIntentSetcontaining all intents.IntentSetand(IntentSet other)Performs a logical AND of this intent set with the other intent set.IntentSetandNot(IntentSet other)Performs a logical AND NOT of this intent set with the other intent set.EnumSet<Intent>asEnumSet()Gets thisIntentSetas anEnumSet.booleancontains(Object o)booleanequals(Object o)longgetRawValue()Gets the raw value for thisIntentSet.inthashCode()Iterator<Intent>iterator()static IntentSetnone()Returns aIntentSetcontaining no intents.static IntentSetnonPrivileged()Returns aIntentSetcontaining non-privileged intents.IntentSetnot()Performs a logical NOT of this intent set.static IntentSetof(long rawValue)Returns aIntentSetcontaining all the intents represented by the raw value.static IntentSetof(Intent... intents)Returns aIntentSetcontaining all the supplied intents.IntentSetor(IntentSet other)Performs a logical OR of this intent set with the other intent set.intsize()StringtoString()IntentSetxor(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 aIntentSetcontaining all intents.- Returns:
- A
IntentSetcontaining all intents.
-
none
public static IntentSet none()
Returns aIntentSetcontaining no intents.- Returns:
- A
IntentSetcontaining no intents.
-
nonPrivileged
public static IntentSet nonPrivileged()
Returns aIntentSetcontaining non-privileged intents.- Returns:
- A
IntentSetcontaining non-privileged intents. - See Also:
- Privileged Intents
-
of
public static IntentSet of(long rawValue)
Returns aIntentSetcontaining all the intents represented by the raw value.- Parameters:
rawValue- A bit-wise OR evaluation of multiple values returned byIntent.getValue().- Returns:
- A
IntentSetcontaining all the intents represented by the raw value.
-
of
public static IntentSet of(Intent... intents)
Returns aIntentSetcontaining all the supplied intents.- Parameters:
intents- The intents to add to theIntentSet.- Returns:
- A
IntentSetcontaining 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 thisIntentSetas anEnumSet.- Returns:
- This
IntentSetas 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:
containsin interfaceCollection<Intent>- Specified by:
containsin interfaceSet<Intent>- Overrides:
containsin classAbstractCollection<Intent>
-
size
public int size()
- Specified by:
sizein interfaceCollection<Intent>- Specified by:
sizein interfaceSet<Intent>- Specified by:
sizein classAbstractCollection<Intent>
-
equals
public boolean equals(@Nullable Object o)
- Specified by:
equalsin interfaceCollection<Intent>- Specified by:
equalsin interfaceSet<Intent>- Overrides:
equalsin classAbstractSet<Intent>
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceCollection<Intent>- Specified by:
hashCodein interfaceSet<Intent>- Overrides:
hashCodein classAbstractSet<Intent>
-
toString
public String toString()
- Overrides:
toStringin classAbstractCollection<Intent>
-
-