Interface CommandBuilderSupport<B extends CommandBuilderSupport<B>>

All Known Subinterfaces:
CommandBuilder<B>, ScmCommandBuilder<B>

@NotThreadSafe public interface CommandBuilderSupport<B extends CommandBuilderSupport<B>>
Provides a unifying abstraction for common functionality expected to be provided by both free-form CommandBuilders and, for those plugins which choose to provide them, type-safe builders.
  • Method Details

    • build

      @Nonnull <T> Command<T> build(@Nonnull CommandOutputHandler<T> outputHandler)
      Builds a Command which, when executed, will provide output to the provided outputHandler for processing.
      Type Parameters:
      T - type for the builder
      Parameters:
      outputHandler - the handler to receive and process output from the command as it executes
      Returns:
      the built command
      Throws:
      NullPointerException - if the provided outputHandler is null
    • clearEnvironment

      @Nonnull B clearEnvironment()
      Clears any environment variables which have been set.
      Returns:
      this
    • defaultExitHandler

      @Nonnull B defaultExitHandler()
      Applies the default CommandExitHandler. The default exit handler used is based on the builder in play; each builder is free to define its own default exit handler.

      Note: If no explicit exit handler is set, the default will be applied automatically when the command is built; it is not possible to build a command without an exit handler.

      Returns:
      this
    • exitHandler

      @Nonnull B exitHandler(@Nonnull CommandExitHandler value)
      Sets the CommandExitHandler which should be invoked after the command exits. This handler receives:
      • the exit code from the process
      • any Throwable thrown during processing
      • any output the process wrote to its error stream
      Whether the command executes successfully or fails in some way (either in the command itself or in processing performed by handlers attached to the command), the exit handler is guaranteed to be invoked.
      Parameters:
      value - the handler which should be invoked when the command exits
      Returns:
      this
      Throws:
      NullPointerException - if the provided value is null
    • removeEnvironment

      @Nonnull B removeEnvironment(@Nonnull String name)
      Removes the environment variable with the provided name if it has been set
      Parameters:
      name - the name of the environment variable to clear
      Returns:
      this
      Throws:
      IllegalArgumentException - if name is empty or blank
      NullPointerException - if name is null
      Since:
      5.12
    • withEnvironment

      @Nonnull B withEnvironment(@Nonnull String name, @Nonnull String value)
      Adds an environment variable with the specified name and value. Both parameters are required, and an exception will be thrown if either is not provided.
      Parameters:
      name - the name of the environment variable to set
      value - the value to set for the environment variable
      Returns:
      this
      Throws:
      IllegalArgumentException - if name or value is empty or blank
      NullPointerException - if name or value is null
      Since:
      4.8