| Modifier and Type | Field and Description |
|---|---|
protected Converter<T> |
converter
the converter to create the value.
|
protected String |
listSeparator
the split character used if the raw value needs to be parsed as a list.
|
protected boolean |
parsedAsList
whether or not the raw value should be parsed as a list.
|
protected Class<T> |
type
The type of the option.
|
argName, choices, DEFAULT_ARG_NAME, defaultValue, description, flag, help, hidden, longName, multiValued, NO_NAME, required, shortName, singleValued| Constructor and Description |
|---|
TypedOption()
Creates an empty instance of
TypedOption. |
TypedOption(TypedOption<T> option)
Creates an instance of
TypedOption by copying the state of another TypedOption |
| Modifier and Type | Method and Description |
|---|---|
TypedOption<T> |
addChoice(String choice)
Adds a choice to the list of values accepted by this option.
|
void |
ensureValidity()
Checks whether or not the option is valid.
|
Converter<T> |
getConverter() |
String |
getListSeparator() |
Class<T> |
getType() |
boolean |
isParsedAsList() |
TypedOption<T> |
setArgName(String argName)
Sets te arg name for this option.
|
TypedOption<T> |
setChoices(Set<String> choices)
Sets the list of values accepted by this option.
|
TypedOption<T> |
setConverter(Converter<T> converter) |
TypedOption<T> |
setDefaultValue(String defaultValue)
Sets the default value of this option
|
TypedOption<T> |
setDescription(String description)
Sets te description of this option.
|
TypedOption<T> |
setFlag(boolean flag)
Configures the current
Option to be a flag. |
TypedOption<T> |
setHidden(boolean hidden)
Sets whether or not this option should be hidden
|
TypedOption<T> |
setListSeparator(String listSeparator) |
TypedOption<T> |
setLongName(String longName)
Sets the long name of this option.
|
TypedOption<T> |
setMultiValued(boolean acceptMultipleValues)
Sets whether or not this option can receive several values.
|
TypedOption<T> |
setParsedAsList(boolean isList) |
TypedOption<T> |
setRequired(boolean required)
Sets whether or not this option is mandatory.
|
TypedOption<T> |
setShortName(String shortName)
Sets the short name of this option.
|
TypedOption<T> |
setSingleValued(boolean acceptSingleValue)
Sets whether or not this option can receive a value.
|
TypedOption<T> |
setType(Class<T> type) |
acceptValue, getArgName, getChoices, getDefaultValue, getDescription, getLongName, getName, getShortName, isFlag, isHelp, isHidden, isMultiValued, isRequired, isSingleValued, setHelp, toJsonprotected boolean parsedAsList
protected String listSeparator
',' is used by default.public TypedOption()
TypedOption.public TypedOption(TypedOption<T> option)
TypedOption by copying the state of another TypedOptionoption - the copied optionpublic TypedOption<T> setMultiValued(boolean acceptMultipleValues)
OptionsetMultiValued in class OptionacceptMultipleValues - whether or not this option is multi-valued.Option instancepublic TypedOption<T> setSingleValued(boolean acceptSingleValue)
OptionsetSingleValued in class OptionacceptSingleValue - whether or not this option is single-valued.Option instancepublic TypedOption<T> setArgName(String argName)
OptionsetArgName in class OptionargName - the arg name, must not be nullOption instancepublic TypedOption<T> setDefaultValue(String defaultValue)
OptionsetDefaultValue in class OptiondefaultValue - the default valueOption instancepublic TypedOption<T> setDescription(String description)
OptionsetDescription in class Optiondescription - the descriptionOption instancepublic TypedOption<T> setFlag(boolean flag)
OptionOption to be a flag. It will be evaluated to true if it's found in
the command line. If you need a flag that may receive a value, use, in this order:
option.setFlag(true).setSingleValued(true)
public TypedOption<T> setHidden(boolean hidden)
Optionpublic TypedOption<T> setLongName(String longName)
OptionsetLongName in class OptionlongName - the long nameOption instancepublic TypedOption<T> setRequired(boolean required)
OptionsetRequired in class Optionrequired - true to make this option mandatory, false otherwiseOption instancepublic TypedOption<T> setShortName(String shortName)
OptionsetShortName in class OptionshortName - the short nameOption instancepublic TypedOption<T> setType(Class<T> type)
public boolean isParsedAsList()
public TypedOption<T> setParsedAsList(boolean isList)
public String getListSeparator()
public TypedOption<T> setListSeparator(String listSeparator)
public TypedOption<T> setConverter(Converter<T> converter)
public void ensureValidity()
OptionCLI is valid before starting the parsing.
If the configuration is not valid, this method throws a IllegalArgumentException.ensureValidity in class Optionpublic TypedOption<T> setChoices(Set<String> choices)
OptionInvalidValueException exception is thrown.setChoices in class Optionchoices - the choicesOptionpublic TypedOption<T> addChoice(String choice)
OptionInvalidValueException exception is thrown.Copyright © 2022 Eclipse. All rights reserved.