Class TypedOption<T>
java.lang.Object
io.vertx.core.cli.Option
io.vertx.core.cli.TypedOption<T>
An implementation of
Option for java specifying the type of
object received by the option. This allows converting the given raw value into the specified type.- Author:
- Clement Escoffier invalid input: '<'[email protected]>
-
Field Summary
FieldsModifier and TypeFieldDescriptionthe converter to create the value.protected Stringthe split character used if the raw value needs to be parsed as a list.protected booleanwhether or not the raw value should be parsed as a list.The type of the option.Fields inherited from class Option
argName, choices, DEFAULT_ARG_NAME, defaultValue, description, flag, help, hidden, longName, multiValued, NO_NAME, required, shortName, singleValued -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty instance ofTypedOption.TypedOption(TypedOption<T> option) Creates an instance ofTypedOptionby copying the state of anotherTypedOption -
Method Summary
Modifier and TypeMethodDescriptionAdds a choice to the list of values accepted by this option.voidChecks whether or not the option is valid.getType()booleansetArgName(String argName) Sets te arg name for this option.setChoices(Set<String> choices) Sets the list of values accepted by this option.setConverter(Converter<T> converter) setDefaultValue(String defaultValue) Sets the default value of this optionsetDescription(String description) Sets te description of this option.setFlag(boolean flag) Configures the currentOptionto be a flag.setHidden(boolean hidden) Sets whether or not this option should be hiddensetListSeparator(String listSeparator) setLongName(String longName) Sets the long name of this option.setMultiValued(boolean acceptMultipleValues) Sets whether or not this option can receive several values.setParsedAsList(boolean isList) setRequired(boolean required) Sets whether or not this option is mandatory.setShortName(String shortName) Sets the short name of this option.setSingleValued(boolean acceptSingleValue) Sets whether or not this option can receive a value.Methods inherited from class Option
acceptValue, getArgName, getChoices, getDefaultValue, getDescription, getLongName, getName, getShortName, isFlag, isHelp, isHidden, isMultiValued, isRequired, isSingleValued, setHelp, toJson
-
Field Details
-
type
-
parsedAsList
protected boolean parsedAsListwhether or not the raw value should be parsed as a list. The list if computed by splitting the value. -
listSeparator
the split character used if the raw value needs to be parsed as a list.','is used by default. -
converter
-
-
Constructor Details
-
TypedOption
public TypedOption()Creates an empty instance ofTypedOption. -
TypedOption
Creates an instance ofTypedOptionby copying the state of anotherTypedOption- Parameters:
option- the copied option
-
-
Method Details
-
setMultiValued
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
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
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
Description copied from class:OptionSets the default value of this option- Overrides:
setDefaultValuein classOption- Parameters:
defaultValue- the default value- Returns:
- the current
Optioninstance
-
setDescription
Description copied from class:OptionSets te description of this option.- Overrides:
setDescriptionin classOption- Parameters:
description- the description- Returns:
- the current
Optioninstance
-
setFlag
-
setHidden
Description copied from class:OptionSets whether or not this option should be hidden -
setLongName
Description copied from class:OptionSets the long name of this option.- Overrides:
setLongNamein classOption- Parameters:
longName- the long name- Returns:
- the current
Optioninstance
-
setRequired
Description copied from class:OptionSets whether or not this option is mandatory.- Overrides:
setRequiredin classOption- Parameters:
required-trueto make this option mandatory,} otherwiseinvalid @link
{@link false- Returns:
- the current
Optioninstance
-
setShortName
Description copied from class:OptionSets the short name of this option.- Overrides:
setShortNamein classOption- Parameters:
shortName- the short name- Returns:
- the current
Optioninstance
-
getType
-
setType
-
isParsedAsList
public boolean isParsedAsList() -
setParsedAsList
-
getListSeparator
-
setListSeparator
-
getConverter
-
setConverter
-
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
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
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.
-