Enum User.UserFlag

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<User.UserFlag>
    Enclosing interface:
    User

    public static enum User.UserFlag
    extends java.lang.Enum<User.UserFlag>
    Represents the bit offsets used by Discord for public flags
    • Field Detail

      • EMPTY_FLAGS

        public static final User.UserFlag[] EMPTY_FLAGS
        Empty array of UserFlag enum, useful for optimized use in Collection.toArray(Object[]).
    • Method Detail

      • values

        public static User.UserFlag[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (User.UserFlag c : User.UserFlag.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static User.UserFlag valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getName

        @Nonnull
        public java.lang.String getName()
        The readable name as used in the Discord Client.
        Returns:
        The readable name of this UserFlag.
      • getOffset

        public int getOffset()
        The binary offset of the flag.
        Returns:
        The offset that represents this UserFlag.
      • getRawValue

        public int getRawValue()
        The value of this flag when viewed as raw value.
        This is equivalent to: 1 << getOffset()
        Returns:
        The raw value of this specific flag.
      • getFromOffset

        @Nonnull
        public static User.UserFlag getFromOffset​(int offset)
        Gets the first UserFlag relating to the provided offset.
        If there is no UserFlag that matches the provided offset, UNKNOWN is returned.
        Parameters:
        offset - The offset to match a UserFlag to.
        Returns:
        UserFlag relating to the provided offset.
      • getFlags

        @Nonnull
        public static java.util.EnumSet<User.UserFlag> getFlags​(int flags)
        A set of all UserFlags that are specified by this raw int representation of flags.
        Parameters:
        flags - The raw int representation if flags.
        Returns:
        Possibly-empty EnumSet of UserFlags.
      • getRaw

        public static int getRaw​(@Nonnull
                                 User.UserFlag... flags)
        This is effectively the opposite of getFlags(int), this takes 1 or more UserFlags and returns the bitmask representation of the flags.
        Parameters:
        flags - The array of flags of which to form into the raw int representation.
        Returns:
        bitmask representing the provided flags.
        Throws:
        java.lang.IllegalArgumentException - When the provided UserFlags are null.
      • getRaw

        public static int getRaw​(@Nonnull
                                 java.util.Collection<User.UserFlag> flags)
        This is effectively the opposite of getFlags(int). This takes a collection of UserFlags and returns the bitmask representation of the flags.
        Example: getRaw(EnumSet.of(UserFlag.STAFF, UserFlag.HYPESQUAD))
        Parameters:
        flags - The flags to convert
        Returns:
        bitmask representing the provided flags.
        Throws:
        java.lang.IllegalArgumentException - When the provided UserFLags are null.
        See Also:
        EnumSet