public class AppendConstArgumentAction extends Object implements 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 and Description |
---|
AppendConstArgumentAction() |
Modifier and Type | Method and Description |
---|---|
boolean |
consumeArgument()
Returns
true if this action consumes argument. |
void |
onAttach(Argument arg)
Called when ArgumentAction is added to
Argument using
Argument.action(ArgumentAction) . |
void |
run(ArgumentParser parser,
Argument arg,
Map<String,Object> attrs,
String flag,
Object value)
Executes this action.
|
public void run(ArgumentParser parser, Argument arg, Map<String,Object> attrs, String flag, Object value) throws ArgumentParserException
ArgumentAction
Executes this action.
If the objects derived from RuntimeException
are thrown in this
method because of invalid input from command line, subclass must catch
these exceptions and wrap them in ArgumentParserException
and
give simple error message to explain what happened briefly.
run
in interface ArgumentAction
parser
- The parser.arg
- The argument this action attached to.attrs
- Map to store attributes.flag
- The actual option flag in command line if arg
is a
named arguments. null
if arg
is a
positional argument.value
- The attribute value. This may be null if this action does not
consume any arguments.ArgumentParserException
- If error occurred.public boolean consumeArgument()
ArgumentAction
true
if this action consumes argument. Otherwise returns
false
.consumeArgument
in interface ArgumentAction
true
or false
.public void onAttach(Argument arg)
ArgumentAction
Argument
using
Argument.action(ArgumentAction)
.onAttach
in interface ArgumentAction
arg
- Argument
object to which this object is added.Copyright © 2012–2017. All rights reserved.