Class OptionMapping

    • Constructor Detail

      • OptionMapping

        public OptionMapping​(DataObject data,
                             gnu.trove.map.TLongObjectMap<java.lang.Object> resolved)
    • Method Detail

      • getName

        @Nonnull
        public java.lang.String getName()
        The name of this option.
        Returns:
        The option name
      • getAsString

        @Nonnull
        public java.lang.String getAsString()
        The String representation of this option value.
        This will automatically convert the value to a string if the type is not OptionType.STRING.
        This will be the ID of any resolved entity such as Role or Member.
        Returns:
        The String representation of this option value
      • getAsBoolean

        public boolean getAsBoolean()
        The boolean value.
        Returns:
        The boolean value
        Throws:
        java.lang.IllegalStateException - If this option is not of type BOOLEAN
      • getAsLong

        public long getAsLong()
        The long value for this option.
        This will be the ID of any resolved entity such as Role or Member.
        Returns:
        The long value
        Throws:
        java.lang.IllegalStateException - If this option type cannot be converted to a long
        java.lang.NumberFormatException - If this option is of type STRING and could not be parsed to a valid long value
      • getAsDouble

        public double getAsDouble()
        The double value for this option.
        Returns:
        The double value
        Throws:
        java.lang.IllegalStateException - If this option type cannot be converted to a double
        java.lang.NumberFormatException - If this option is of type STRING and could not be parsed to a valid double value
      • getAsMentionable

        @Nonnull
        public IMentionable getAsMentionable()
        The resolved IMentionable instance for this option value.
        Returns:
        The resolved IMentionable
        Throws:
        java.lang.IllegalStateException - If the mentioned entity is not resolvable
      • getAsMember

        @Nullable
        public Member getAsMember()
        The resolved Member for this option value.
        Note that OptionType.USER can also accept users that are not members of a guild, in which case this will be null!
        Returns:
        The resolved Member, or null
        Throws:
        java.lang.IllegalStateException - If this option is not of type USER
      • getAsUser

        @Nonnull
        public User getAsUser()
        The resolved User for this option value.
        Returns:
        The resolved User
        Throws:
        java.lang.IllegalStateException - If this option is not of type USER
      • getAsRole

        @Nonnull
        public Role getAsRole()
        The resolved Role for this option value.
        Returns:
        The resolved Role
        Throws:
        java.lang.IllegalStateException - If this option is not of type ROLE
      • getAsGuildChannel

        @Nonnull
        public GuildChannel getAsGuildChannel()
        The resolved GuildChannel for this option value.
        Note that OptionType.CHANNEL can accept channels of any type!
        Returns:
        The resolved GuildChannel
        Throws:
        java.lang.IllegalStateException - If this option is not of type CHANNEL or could not be resolved for unexpected reasons
      • getAsMessageChannel

        @Nullable
        public MessageChannel getAsMessageChannel()
        The resolved MessageChannel for this option value.
        Note that OptionType.CHANNEL can accept channels of any type!
        Returns:
        The resolved MessageChannel, or null if this was not a message channel
        Throws:
        java.lang.IllegalStateException - If this option is not of type CHANNEL
      • getChannelType

        @Nonnull
        public ChannelType getChannelType()
        The ChannelType for the resolved channel.
        Returns:
        The ChannelType
        Throws:
        java.lang.IllegalStateException - If this option is not of type CHANNEL
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object