Package io.vertx.core.cli
Class TypedOption<T>
- java.lang.Object
-
- io.vertx.core.cli.Option
-
- io.vertx.core.cli.TypedOption<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected Converter<T>converterthe converter to create the value.protected StringlistSeparatorthe split character used if the raw value needs to be parsed as a list.protected booleanparsedAsListwhether or not the raw value should be parsed as a list.protected Class<T>typeThe type of the option.-
Fields inherited from class io.vertx.core.cli.Option
argName, choices, DEFAULT_ARG_NAME, defaultValue, description, flag, help, hidden, longName, multiValued, NO_NAME, required, shortName, singleValued
-
-
Constructor Summary
Constructors Constructor Description TypedOption()Creates an empty instance ofTypedOption.TypedOption(TypedOption<T> option)Creates an instance ofTypedOptionby copying the state of anotherTypedOption
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TypedOption<T>addChoice(String choice)Adds a choice to the list of values accepted by this option.voidensureValidity()Checks whether or not the option is valid.Converter<T>getConverter()StringgetListSeparator()Class<T>getType()booleanisParsedAsList()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 optionTypedOption<T>setDescription(String description)Sets te description of this option.TypedOption<T>setFlag(boolean flag)Configures the currentOptionto be a flag.TypedOption<T>setHidden(boolean hidden)Sets whether or not this option should be hiddenTypedOption<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)-
Methods inherited from class io.vertx.core.cli.Option
acceptValue, getArgName, getChoices, getDefaultValue, getDescription, getLongName, getName, getShortName, isFlag, isHelp, isHidden, isMultiValued, isRequired, isSingleValued, setHelp, toJson
-
-
-
-
Field Detail
-
parsedAsList
protected boolean parsedAsList
whether or not the raw value should be parsed as a list. The list if computed by splitting the value.
-
listSeparator
protected String listSeparator
the split character used if the raw value needs to be parsed as a list.','is used by default.
-
-
Constructor Detail
-
TypedOption
public TypedOption()
Creates an empty instance ofTypedOption.
-
TypedOption
public TypedOption(TypedOption<T> option)
Creates an instance ofTypedOptionby copying the state of anotherTypedOption- Parameters:
option- the copied option
-
-
Method Detail
-
setMultiValued
public TypedOption<T> setMultiValued(boolean acceptMultipleValues)
Description copied from class:OptionSets whether or not this option can receive several values.- Overrides:
setMultiValuedin classOption- Parameters:
acceptMultipleValues- whether or not this option is multi-valued.- Returns:
- the current
Optioninstance
-
setSingleValued
public TypedOption<T> setSingleValued(boolean acceptSingleValue)
Description copied from class:OptionSets whether or not this option can receive a value.- Overrides:
setSingleValuedin classOption- Parameters:
acceptSingleValue- whether or not this option is single-valued.- Returns:
- the current
Optioninstance
-
setArgName
public TypedOption<T> setArgName(String argName)
Description copied from class:OptionSets te arg name for this option.- Overrides:
setArgNamein classOption- Parameters:
argName- the arg name, must not benull- Returns:
- the current
Optioninstance
-
setDefaultValue
public TypedOption<T> setDefaultValue(String defaultValue)
Description copied from class:OptionSets the default value of this option- Overrides:
setDefaultValuein classOption- Parameters:
defaultValue- the default value- Returns:
- the current
Optioninstance
-
setDescription
public TypedOption<T> setDescription(String description)
Description copied from class:OptionSets te description of this option.- Overrides:
setDescriptionin classOption- Parameters:
description- the description- Returns:
- the current
Optioninstance
-
setFlag
public TypedOption<T> setFlag(boolean flag)
Description copied from class:OptionConfigures the currentOptionto be a flag. It will be evaluated totrueif 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)
-
setHidden
public TypedOption<T> setHidden(boolean hidden)
Description copied from class:OptionSets whether or not this option should be hidden
-
setLongName
public TypedOption<T> setLongName(String longName)
Description copied from class:OptionSets the long name of this option.- Overrides:
setLongNamein classOption- Parameters:
longName- the long name- Returns:
- the current
Optioninstance
-
setRequired
public TypedOption<T> setRequired(boolean required)
Description copied from class:OptionSets whether or not this option is mandatory.- Overrides:
setRequiredin classOption- Parameters:
required-trueto make this option mandatory, {@link false} otherwise- Returns:
- the current
Optioninstance
-
setShortName
public TypedOption<T> setShortName(String shortName)
Description copied from class:OptionSets the short name of this option.- Overrides:
setShortNamein classOption- Parameters:
shortName- the short name- Returns:
- the current
Optioninstance
-
setType
public TypedOption<T> setType(Class<T> type)
-
isParsedAsList
public boolean isParsedAsList()
-
setParsedAsList
public TypedOption<T> setParsedAsList(boolean isList)
-
getListSeparator
public String getListSeparator()
-
setListSeparator
public TypedOption<T> setListSeparator(String listSeparator)
-
setConverter
public TypedOption<T> setConverter(Converter<T> converter)
-
ensureValidity
public void ensureValidity()
Description copied from class:OptionChecks whether or not the option is valid. This implementation check that it has a short name or a long name. This method is intended to be extended by sub-class. Parser should check that the set of option of aCLIis valid before starting the parsing. If the configuration is not valid, this method throws aIllegalArgumentException.- Overrides:
ensureValidityin classOption
-
setChoices
public TypedOption<T> setChoices(Set<String> choices)
Description copied from class:OptionSets the list of values accepted by this option. If the value set by the user does not match once of these values, aInvalidValueExceptionexception is thrown.- Overrides:
setChoicesin classOption- Parameters:
choices- the choices- Returns:
- the current
Option
-
addChoice
public TypedOption<T> addChoice(String choice)
Description copied from class:OptionAdds a choice to the list of values accepted by this option. If the value set by the user does not match once of these values, aInvalidValueExceptionexception is thrown.
-
-