Class CommandContext.Builder<M>

  • Type Parameters:
    M - the class of the messages for which the built command contexts are used
    Enclosing class:
    CommandContext<M>

    public static class CommandContext.Builder<M>
    extends Object
    A builder to build command context instances. This builder is not thread-safe.
    • Constructor Detail

      • Builder

        public Builder​(M message,
                       String messageContent)
        Constructs a new command context builder with the given message and message content.
        Parameters:
        message - the message that triggered the command processing
        messageContent - the content of the message that triggered the command processing
    • Method Detail

      • withMessage

        public CommandContext.Builder<M> withMessage​(M message)
        Sets the message that triggered the command processing and returns this builder for method call chaining.
        Parameters:
        message - the message that triggered the command processing
        Returns:
        this builder
      • withMessageContent

        public CommandContext.Builder<M> withMessageContent​(String messageContent)
        Sets the content of the message that triggered the command processing and returns this builder for method call chaining.
        Parameters:
        messageContent - the content of the message that triggered the command processing
        Returns:
        this builder
      • withPrefix

        public CommandContext.Builder<M> withPrefix​(String prefix)
        Sets the prefix that the message has to start with to trigger a command and returns this builder for method call chaining.
        Parameters:
        prefix - the prefix that the message has to start with to trigger a command
        Returns:
        this builder
      • withAlias

        public CommandContext.Builder<M> withAlias​(String alias)
        Sets the alias of the triggered command and returns this builder for method call chaining.
        Parameters:
        alias - the alias of the triggered command
        Returns:
        this builder
      • withParameterString

        public CommandContext.Builder<M> withParameterString​(String parameterString)
        Sets the parameter string to be processed by the triggered command and returns this builder for method call chaining.
        Parameters:
        parameterString - the parameter string to be processed by the triggered command
        Returns:
        this builder
      • withCommand

        public CommandContext.Builder<M> withCommand​(Command<? super M> command)
        Sets the command that is triggered and returns this builder for method call chaining.
        Parameters:
        command - the command that is triggered
        Returns:
        this builder
      • withAdditionalData

        public CommandContext.Builder<M> withAdditionalData​(String key,
                                                            Object value)
        Sets the additional data for the given key to the given value and returns this builder for method call chaining.
        Parameters:
        key - the additional data key whose value is to be set
        value - the value to set for the given key
        Returns:
        this builder
      • withoutAdditionalData

        public CommandContext.Builder<M> withoutAdditionalData​(String key)
        Removes the additional data for the given key and returns this builder for method call chaining.
        Parameters:
        key - the additional data key whose value is to be removed
        Returns:
        this builder
      • withoutAdditionalData

        public CommandContext.Builder<M> withoutAdditionalData()
        Removes all additional data and returns this builder for method call chaining.
        Returns:
        this builder
      • build

        public CommandContext<M> build()
        Returns a new command context instance from the current values. Calling this method multiple times creates a new command context instance each time with the current values. Modifying this builder after calling this method does not influence previously built command context instances.
        Returns:
        a new command context instance from the current values
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object