public class CommandScope extends Object
execute()
is called.
Named similarly to Scope
because they both define a self-contained unit of values, but this
scope is specific to a command rather than being a global scope.
Modifier and Type | Field and Description |
---|---|
static Pattern |
NO_PREFIX_PATTERN |
Constructor and Description |
---|
CommandScope(String... commandName)
Creates a new scope for the given command.
|
Modifier and Type | Method and Description |
---|---|
<T> CommandScope |
addArgumentValue(CommandArgumentDefinition<T> argument,
T value)
Adds the given key/value pair to the stored argument data.
|
CommandScope |
addArgumentValue(String argument,
Object value)
Adds the given key/value pair to the stored argument data.
|
CommandResults |
execute()
Executes the command in this scope, and returns the results.
|
<T> T |
getArgumentValue(CommandArgumentDefinition<T> argument)
Convenience method for
getConfiguredValue(CommandArgumentDefinition) , returning ConfiguredValue.getValue() along with any
CommandArgumentDefinition.getValueConverter() applied |
CommandDefinition |
getCommand()
Returns the
CommandDefinition for the command in this scope. |
String |
getCompleteConfigPrefix()
Returns the complete config prefix (without a trailing period) for the command in this scope.
|
<T> ConfiguredValue<T> |
getConfiguredValue(CommandArgumentDefinition<T> argument)
Returns the detailed information about how an argument is set.
|
<T> Object |
getDependency(Class<T> clazz)
Retrieves the registered dependency object provided by this class identifier
|
CommandScope |
provideDependency(Class<?> clazz,
Object value)
Assign a value to a given provided dependency.
|
CommandScope |
setOutput(OutputStream outputStream)
Sets the output stream for this command.
|
void |
validate() |
public static final Pattern NO_PREFIX_PATTERN
public CommandScope(String... commandName) throws CommandExecutionException
CommandExecutionException
public CommandDefinition getCommand()
CommandDefinition
for the command in this scope.public String getCompleteConfigPrefix()
public CommandScope addArgumentValue(String argument, Object value)
for a type-safe version
public <T> CommandScope addArgumentValue(CommandArgumentDefinition<T> argument, T value)
public <T> ConfiguredValue<T> getConfiguredValue(CommandArgumentDefinition<T> argument)
addArgumentValue(String, Object)
, but will also check LiquibaseConfiguration
for settings of liquibase.command.${commandName(s)}.${argumentName} or liquibase.command.${argumentName}public <T> T getArgumentValue(CommandArgumentDefinition<T> argument)
getConfiguredValue(CommandArgumentDefinition)
, returning ConfiguredValue.getValue()
along with any
CommandArgumentDefinition.getValueConverter()
appliedpublic CommandScope provideDependency(Class<?> clazz, Object value)
CommandStep.run(CommandResultsBuilder)
method it needs to provide the value for X using this method.
commandScope.provideDependency(LockService.class, lockService);
Means that this class will LockService.class using object lockpublic <T> Object getDependency(Class<T> clazz)
public CommandScope setOutput(OutputStream outputStream)
public void validate() throws CommandValidationException
CommandValidationException
public CommandResults execute() throws CommandExecutionException
CommandExecutionException
Copyright © 2023 Liquibase.org. All rights reserved.