Package com.atlassian.bitbucket.scm
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
CommandBuilder
s and, for those plugins which choose to provide them, type-safe builders.-
Method Summary
Modifier and TypeMethodDescription<T> Command<T>
build
(CommandOutputHandler<T> outputHandler) Clears any environment variables which have been set.Applies the defaultCommandExitHandler
.exitHandler
(CommandExitHandler value) Sets theCommandExitHandler
which should be invoked after the command exits.removeEnvironment
(String name) Removes the environment variable with the providedname
if it has been setwithEnvironment
(String name, String value) Adds an environment variable with the specifiedname
andvalue
.
-
Method Details
-
build
Builds aCommand
which, whenexecuted
, will provide output to the providedoutputHandler
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 providedoutputHandler
isnull
-
clearEnvironment
Clears any environment variables which have been set.- Returns:
this
-
defaultExitHandler
Applies the defaultCommandExitHandler
. 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 isbuilt
; it is not possible to build a command without an exit handler.- Returns:
this
-
exitHandler
Sets theCommandExitHandler
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
- Parameters:
value
- the handler which should be invoked when the command exits- Returns:
this
- Throws:
NullPointerException
- if the providedvalue
isnull
-
removeEnvironment
Removes the environment variable with the providedname
if it has been set- Parameters:
name
- the name of the environment variable to clear- Returns:
this
- Throws:
IllegalArgumentException
- ifname
is empty or blankNullPointerException
- ifname
isnull
- Since:
- 5.12
-
withEnvironment
Adds an environment variable with the specifiedname
andvalue
. Both parameters are required, and an exception will be thrown if either is not provided.- Parameters:
name
- the name of the environment variable to setvalue
- the value to set for the environment variable- Returns:
this
- Throws:
IllegalArgumentException
- ifname
orvalue
is empty or blankNullPointerException
- ifname
orvalue
isnull
- Since:
- 4.8
-