Class IntentSet

All Implemented Interfaces:
Iterable<Intent>, Collection<Intent>, Set<Intent>

public final class IntentSet extends AbstractSet<Intent>
An immutable, specialized Set<Intent>.

This is a value-based class; use of identity-sensitive operations (including reference equality (==), identity hash code, or synchronization) on instances of IntentSet may have unpredictable results and should be avoided. The equals method should be used for comparisons.

See Also:
  • Method Details

    • all

      public static IntentSet all()
      Returns a IntentSet containing all intents.
      Returns:
      A IntentSet containing all intents.
    • none

      public static IntentSet none()
      Returns a IntentSet containing no intents.
      Returns:
      A IntentSet containing no intents.
    • nonPrivileged

      public static IntentSet nonPrivileged()
      Returns a IntentSet containing non-privileged intents.
      Returns:
      A IntentSet containing non-privileged intents.
      See Also:
    • of

      public static IntentSet of(long rawValue)
      Returns a IntentSet containing all the intents represented by the raw value.
      Parameters:
      rawValue - A bit-wise OR evaluation of multiple values returned by Intent.getValue().
      Returns:
      A IntentSet containing all the intents represented by the raw value.
    • of

      public static IntentSet of(Intent... intents)
      Returns a IntentSet containing all the supplied intents.
      Parameters:
      intents - The intents to add to the IntentSet.
      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 this IntentSet as an EnumSet.
      Returns:
      This IntentSet as an EnumSet.
    • getRawValue

      public long getRawValue()
      Gets the raw value for this IntentSet.
      Returns:
      The raw value for this IntentSet.
      See Also:
    • contains

      public boolean contains(Object o)
      Specified by:
      contains in interface Collection<Intent>
      Specified by:
      contains in interface Set<Intent>
      Overrides:
      contains in class AbstractCollection<Intent>
    • iterator

      public Iterator<Intent> iterator()
      Specified by:
      iterator in interface Collection<Intent>
      Specified by:
      iterator in interface Iterable<Intent>
      Specified by:
      iterator in interface Set<Intent>
      Specified by:
      iterator in class AbstractCollection<Intent>
    • size

      public int size()
      Specified by:
      size in interface Collection<Intent>
      Specified by:
      size in interface Set<Intent>
      Specified by:
      size in class AbstractCollection<Intent>
    • equals

      public boolean equals(@Nullable Object o)
      Specified by:
      equals in interface Collection<Intent>
      Specified by:
      equals in interface Set<Intent>
      Overrides:
      equals in class AbstractSet<Intent>
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Collection<Intent>
      Specified by:
      hashCode in interface Set<Intent>
      Overrides:
      hashCode in class AbstractSet<Intent>
    • toString

      public String toString()
      Overrides:
      toString in class AbstractCollection<Intent>