Class AppendConstArgumentAction
- All Implemented Interfaces:
ArgumentAction
Argument action to store a list.
This action appends the value specified by Argument.setConst(Object)
to the list. (Note that the const value defaults to null.) The list
is of type List. This action is typically useful when
multiple arguments need to store constants to the same list. If attrs
contains non-List object for key Argument.getDest(), it will be
overwritten by the List containing value. consumeArgument()
always returns false.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif this action consumes argument.voidCalled when ArgumentAction is added toArgumentusingArgument.action(ArgumentAction).voidExecutes this action.voidrun(ArgumentParser parser, Argument arg, Map<String, Object> attrs, String flag, Object value, Consumer<Object> valueSetter) Executes this action.
-
Constructor Details
-
AppendConstArgumentAction
public AppendConstArgumentAction()
-
-
Method Details
-
run
public void run(ArgumentParser parser, Argument arg, Map<String, Object> attrs, String flag, Object value) Description copied from interface:ArgumentActionExecutes this action.
If the objects derived from
RuntimeExceptionare thrown in this method because of invalid input from command line, subclass must catch these exceptions and wrap them inArgumentParserExceptionand give simple error message to explain what happened briefly.- Specified by:
runin interfaceArgumentAction- Parameters:
parser- The parser.arg- The argument this action attached to.attrs- Map to store attributes.flag- The actual option flag in command line ifargis a named arguments.nullifargis a positional argument.value- The attribute value. This may be null if this action does not consume any arguments.
-
run
public void run(ArgumentParser parser, Argument arg, Map<String, Object> attrs, String flag, Object value, Consumer<Object> valueSetter) Description copied from interface:ArgumentActionExecutes this action.
If the objects derived from
RuntimeExceptionare thrown in this method because of invalid input from command line, subclass must catch these exceptions and wrap them inArgumentParserExceptionand give simple error message to explain what happened briefly.- Specified by:
runin interfaceArgumentAction- Parameters:
parser- The parser.arg- The argument this action attached to.attrs- The current map of attributes. Implementations may read from this map, but may not change it. Implementations must call thevalueSetterwith the actual value to be set.flag- The actual option flag in command line ifargis a named arguments.nullifargis a positional argument.value- The attribute value. This may be null if this action does not consume any arguments.valueSetter- The consumer that will set the actual value determined by this action in the result.
-
consumeArgument
public boolean consumeArgument()Description copied from interface:ArgumentActionReturnstrueif this action consumes argument. Otherwise returnsfalse.- Specified by:
consumeArgumentin interfaceArgumentAction- Returns:
trueorfalse.
-
onAttach
Description copied from interface:ArgumentActionCalled when ArgumentAction is added toArgumentusingArgument.action(ArgumentAction).- Specified by:
onAttachin interfaceArgumentAction- Parameters:
arg-Argumentobject to which this object is added.
-