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, toJson
protected boolean parsedAsList
protected String listSeparator
','
is used by default.public TypedOption()
TypedOption
.public TypedOption(TypedOption<T> option)
TypedOption
by copying the state of another TypedOption
option
- the copied optionpublic TypedOption<T> setMultiValued(boolean acceptMultipleValues)
Option
setMultiValued
in class Option
acceptMultipleValues
- whether or not this option is multi-valued.Option
instancepublic TypedOption<T> setSingleValued(boolean acceptSingleValue)
Option
setSingleValued
in class Option
acceptSingleValue
- whether or not this option is single-valued.Option
instancepublic TypedOption<T> setArgName(String argName)
Option
setArgName
in class Option
argName
- the arg name, must not be null
Option
instancepublic TypedOption<T> setDefaultValue(String defaultValue)
Option
setDefaultValue
in class Option
defaultValue
- the default valueOption
instancepublic TypedOption<T> setDescription(String description)
Option
setDescription
in class Option
description
- the descriptionOption
instancepublic TypedOption<T> setFlag(boolean flag)
Option
Option
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)
Option
public TypedOption<T> setLongName(String longName)
Option
setLongName
in class Option
longName
- the long nameOption
instancepublic TypedOption<T> setRequired(boolean required)
Option
setRequired
in class Option
required
- true
to make this option mandatory, false
otherwiseOption
instancepublic TypedOption<T> setShortName(String shortName)
Option
setShortName
in class Option
shortName
- 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()
Option
CLI
is valid before starting the parsing.
If the configuration is not valid, this method throws a IllegalArgumentException
.ensureValidity
in class Option
public TypedOption<T> setChoices(Set<String> choices)
Option
InvalidValueException
exception is thrown.setChoices
in class Option
choices
- the choicesOption
public TypedOption<T> addChoice(String choice)
Option
InvalidValueException
exception is thrown.Copyright © 2024 Eclipse. All rights reserved.