Interface CommandContext.Builder

All Superinterfaces:
CommandContext, Contextual, Subject, SubjectProxy
Enclosing interface:
CommandContext

public static interface CommandContext.Builder extends CommandContext
A builder for creating this context.
  • Method Details

    • addFlagInvocation

      void addFlagInvocation(Flag flag)
      Adds a flag invocation to the context.
      Parameters:
      flag - The flag to add the invocation for.
    • putEntry

      default <T> void putEntry(Parameter.Value<? super T> parameter, T value)
      Adds a parsed object into the context, for use by commands.
      Type Parameters:
      T - The type of parameter key
      Parameters:
      parameter - The key to store the entry under.
      value - The collection of objects to store.
    • putEntries

      default <T> void putEntries(Parameter.Value<? super T> parameter, Collection<T> value)
      Adds a collection of parsed objects into the context, for use by commands.
      Type Parameters:
      T - The type of parameter key
      Parameters:
      parameter - The key to store the entry under.
      value - The collection of objects to store.
    • putEntries

      default <T> void putEntries(Parameter.Key<? super T> parameter, Collection<T> value)
      Adds a collection of parsed objects into the context, for use by commands.
      Type Parameters:
      T - The type of parameter key
      Parameters:
      parameter - The key to store the entry under.
      value - The collection of objects to store.
    • putEntry

      <T> void putEntry(Parameter.Key<T> key, T object)
      Adds a parsed object into the context, for use by commands.
      Type Parameters:
      T - The type of parameter key
      Parameters:
      key - The key to store the entry under.
      object - The object to store.
    • startTransaction

      Starts a CommandContext.Builder.Transaction which allows for this builder to be returned to a previous state if necessary.

      Multiple transactions can be started on the same builder, however, they must be either committed or rolledback in reverse order (that is, the last transaction must be committed first)

      Transactions must not be held on to for longer than necessary.

      Returns:
      The state.
    • build

      CommandContext build(String input)
      Creates a CommandContext.

      If CommandContext.Builder.Transactions are still open at this point, they will all be committed.

      Parameters:
      input - The input argument string.
      Returns:
      The context
    • commit

      Commits the specified CommandContext.Builder.Transaction if it was the most recently created transaction.
      Parameters:
      transaction - The transaction to commit.
      Throws:
      IllegalArgumentException - Thrown if there are newer transactions to commit first, if this transaction is not active, or if this transaction is not part of this builder.
    • rollback

      Cancels the specified CommandContext.Builder.Transaction if it was the most recently created transaction.
      Parameters:
      transaction - The transaction to rollback.
      Throws:
      IllegalArgumentException - Thrown if there are newer transactions to commit first, if this transaction is not active, or if this transaction is not part of this builder.