public interface IOption
Modifier and Type | Method and Description |
---|---|
default void |
addModifiers(Argument arg)
IOption can have associated IArgumentModifiers that modify different properties of the option
in the context of argparse4j (e.g.
|
default void |
addOption(ArgumentParser parser,
IAction action)
Add the option to an argument parser.
|
ArgumentAction |
getArgumentAction()
Get the associated
ArgumentAction to an option. |
IArgumentModifier[] |
getArgumentModifiers()
Get the associated
IArgumentModifier to an option. |
default <T> boolean |
getBool()
Check whether an boolean option is true or false.
|
String |
getDescription()
Get the description of an option.
|
String |
getEnumName()
Returns the name of the enum entry that represents the option.
|
default IOptionGroup |
getGroup()
Get the group associated with an option.
|
String |
getName()
Get the name of an option as it is supposed to be represented on a command line.
|
default String |
getPlainName()
Returns the option name with all leading dashes being removed.
|
default Class<?> |
getType()
Return the underlying Java type of an option.
|
<T> T |
getValue()
Get the value of an option.
|
default boolean |
isNull()
Return true if the value associated with the option is null.
|
default boolean |
notNull()
Return true if the value associated with the option is not null.
|
default <T> T |
require()
Require an option at runtime.
|
static void |
requireAllOf(IOption... options)
Require that each of the specified options has an value assigned.
|
static <T> T |
requireOneOf(IOption... options)
Require an option or one of the other specified options at runtime.
|
default <T> void |
setValue(Namespace args,
T def)
Set an option value according to the user specified command line.
|
<T> void |
setValue(T value)
Set the value of an option.
|
default <T> void |
setValue(T value,
T def)
Set the option value to the specified value or to the specified default, if the value is null.
|
String getName()
String getDescription()
ArgumentAction getArgumentAction()
ArgumentAction
to an option.ArgumentAction
IArgumentModifier[] getArgumentModifiers()
IArgumentModifier
to an option.IArgumentModifier
as array<T> void setValue(T value)
T
- the type of the value that is setvalue
- the value that is set<T> T getValue()
T
- the type of the options valueString getEnumName()
default String getPlainName()
default IOptionGroup getGroup()
IOptionGroup
associated to an optiondefault boolean isNull()
default boolean notNull()
default <T> boolean getBool()
default <T> void setValue(T value, T def)
T
- the type of the valuevalue
- the specified valuedef
- the specified defaultdefault <T> void setValue(Namespace args, T def)
T
- the type of the valueargs
- the user specified command linedef
- the specified defaultdefault Class<?> getType()
default void addOption(ArgumentParser parser, IAction action)
parser
- the parser to add the option toaction
- the action that is associated with the option (can be null)default void addModifiers(Argument arg)
arg
- the argument to apply the modifiers todefault <T> T require() throws RequirementException
T
- type of the optionRequirementException
- is raised if no value was set for this optionstatic <T> T requireOneOf(IOption... options) throws RequirementException
T
- type of the optionoptions
- list of additional options to requireRequirementException
- is raised if all options have no value assignedstatic void requireAllOf(IOption... options) throws RequirementException
options
- list of additional options to requireRequirementException
- is raised if at least one option has no value assignedCopyright © 2024. All rights reserved.