Top Description Fields Constructors Methods
io.vertx.core.cli

public Class TypedOption<T>

extends Option
Class Inheritance
Imports
io.vertx.core.cli.converters.Converter, java.util.Arrays, .Objects, .Set

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

Field Summary

Modifier and TypeField 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.

Inherited from io.vertx.core.cli.Option:
argNamechoicesDEFAULT_ARG_NAMEdefaultValuedescriptionflaghelphiddenlongNamemultiValuedNO_NAMErequiredshortNamesingleValued

Constructor Summary

AccessConstructor and Description
public
TypedOption()

Creates an empty instance of TypedOption.

public
TypedOption(TypedOption<T>
the copied option
option
)

Creates an instance of TypedOption by copying the state of another TypedOption

Method Summary

Modifier and TypeMethod and Description
public TypedOption<T>
addChoice(String
the choice
choice
)

Overrides io.vertx.core.cli.Option.addChoice.

Adds a choice to the list of values accepted by this option.

public void
ensureValidity()

Overrides io.vertx.core.cli.Option.ensureValidity.

Checks whether or not the option is valid.

public Converter<T>
public String
public Class<T>
public boolean
public TypedOption<T>
setArgName(String
the arg name, must not be null
argName
)

Overrides io.vertx.core.cli.Option.setArgName.

Sets te arg name for this option.

public TypedOption<T>
setChoices(Set<String>
the choices
choices
)

Overrides io.vertx.core.cli.Option.setChoices.

Sets the list of values accepted by this option.

private void
setChoicesFromEnumType()

Sets the list of values accepted by this option from the option's type.

public TypedOption<T>
setConverter(Converter<T> converter)

public TypedOption<T>
setDefaultValue(String
the default value
defaultValue
)

Overrides io.vertx.core.cli.Option.setDefaultValue.

Sets the default value of this option

public TypedOption<T>
setDescription(String
the description
description
)

Overrides io.vertx.core.cli.Option.setDescription.

Sets te description of this option.

public TypedOption<T>
setFlag(boolean
whether or not the option is a flag.
flag
)

Overrides io.vertx.core.cli.Option.setFlag.

Configures the current Option to be a flag.

public TypedOption<T>
setHidden(boolean
true to make this option hidden, false otherwise
hidden
)

Overrides io.vertx.core.cli.Option.setHidden.

Sets whether or not this option should be hidden

public TypedOption<T>
setListSeparator(String listSeparator)

public TypedOption<T>
setLongName(String
the long name
longName
)

Overrides io.vertx.core.cli.Option.setLongName.

Sets the long name of this option.

public TypedOption<T>
setMultiValued(boolean
whether or not this option is multi-valued.
acceptMultipleValues
)

Overrides io.vertx.core.cli.Option.setMultiValued.

Sets whether or not this option can receive several values.

public TypedOption<T>
setParsedAsList(boolean isList)

public TypedOption<T>
setRequired(boolean
true to make this option mandatory, false otherwise
required
)

Overrides io.vertx.core.cli.Option.setRequired.

Sets whether or not this option is mandatory.

public TypedOption<T>
setShortName(String
the short name
shortName
)

Overrides io.vertx.core.cli.Option.setShortName.

Sets the short name of this option.

public TypedOption<T>
setSingleValued(boolean
whether or not this option is single-valued.
acceptSingleValue
)

Overrides io.vertx.core.cli.Option.setSingleValued.

Sets whether or not this option can receive a value.

public TypedOption<T>
setType(Class<T> type)

Inherited from io.vertx.core.cli.Option:
acceptValuegetArgNamegetChoicesgetDefaultValuegetDescriptiongetLongNamegetNamegetShortNameisFlagisHelpisHiddenisMultiValuedisRequiredisSingleValuedsetHelptoJson

Field Detail

converterback to summary
protected Converter<T> converter

the converter to create the value.

listSeparatorback to summary
protected String listSeparator

the split character used if the raw value needs to be parsed as a list. ',' is used by default.

parsedAsListback to summary
protected boolean parsedAsList

whether or not the raw value should be parsed as a list. The list if computed by splitting the value.

typeback to summary
protected Class<T> type

The type of the option.

Constructor Detail

TypedOptionback to summary
public TypedOption()

Creates an empty instance of TypedOption.

TypedOptionback to summary
public TypedOption(TypedOption<T> option)

Creates an instance of TypedOption by copying the state of another TypedOption

Parameters
option:TypedOption<T>

the copied option

Method Detail

addChoiceback to summary
public TypedOption<T> addChoice(String choice)

Overrides io.vertx.core.cli.Option.addChoice.

Doc from io.vertx.core.cli.Option.addChoice.

Adds 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, a InvalidValueException exception is thrown.

Parameters
choice:String

the choice

Returns:TypedOption<T>

the current Option

Annotations
@Override
ensureValidityback to summary
public void ensureValidity()

Overrides io.vertx.core.cli.Option.ensureValidity.

Doc from io.vertx.core.cli.Option.ensureValidity.

Checks 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 a CLI is valid before starting the parsing.

If the configuration is not valid, this method throws a IllegalArgumentException.

Annotations
@Override
getConverterback to summary
public Converter<T> getConverter()
getListSeparatorback to summary
public String getListSeparator()
getTypeback to summary
public Class<T> getType()
isParsedAsListback to summary
public boolean isParsedAsList()
setArgNameback to summary
public TypedOption<T> setArgName(String argName)

Overrides io.vertx.core.cli.Option.setArgName.

Doc from io.vertx.core.cli.Option.setArgName.

Sets te arg name for this option.

Parameters
argName:String

the arg name, must not be null

Returns:TypedOption<T>

the current Option instance

Annotations
@Override
setChoicesback to summary
public TypedOption<T> setChoices(Set<String> choices)

Overrides io.vertx.core.cli.Option.setChoices.

Doc from io.vertx.core.cli.Option.setChoices.

Sets the list of values accepted by this option. If the value set by the user does not match once of these values, a InvalidValueException exception is thrown.

Parameters
choices:Set<String>

the choices

Returns:TypedOption<T>

the current Option

Annotations
@Override
setChoicesFromEnumTypeback to summary
private void setChoicesFromEnumType()

Sets the list of values accepted by this option from the option's type.

setConverterback to summary
public TypedOption<T> setConverter(Converter<T> converter)
setDefaultValueback to summary
public TypedOption<T> setDefaultValue(String defaultValue)

Overrides io.vertx.core.cli.Option.setDefaultValue.

Doc from io.vertx.core.cli.Option.setDefaultValue.

Sets the default value of this option

Parameters
defaultValue:String

the default value

Returns:TypedOption<T>

the current Option instance

Annotations
@Override
setDescriptionback to summary
public TypedOption<T> setDescription(String description)

Overrides io.vertx.core.cli.Option.setDescription.

Doc from io.vertx.core.cli.Option.setDescription.

Sets te description of this option.

Parameters
description:String

the description

Returns:TypedOption<T>

the current Option instance

Annotations
@Override
setFlagback to summary
public TypedOption<T> setFlag(boolean flag)

Overrides io.vertx.core.cli.Option.setFlag.

Doc from io.vertx.core.cli.Option.setFlag.

Configures the current 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)
Parameters
flag:boolean

whether or not the option is a flag.

Returns:TypedOption<T>

the current Option

Annotations
@Override
setHiddenback to summary
public TypedOption<T> setHidden(boolean hidden)

Overrides io.vertx.core.cli.Option.setHidden.

Doc from io.vertx.core.cli.Option.setHidden.

Sets whether or not this option should be hidden

Parameters
hidden:boolean

true to make this option hidden, false otherwise

Returns:TypedOption<T>

the current Option instance

Annotations
@Override
setListSeparatorback to summary
public TypedOption<T> setListSeparator(String listSeparator)
setLongNameback to summary
public TypedOption<T> setLongName(String longName)

Overrides io.vertx.core.cli.Option.setLongName.

Doc from io.vertx.core.cli.Option.setLongName.

Sets the long name of this option.

Parameters
longName:String

the long name

Returns:TypedOption<T>

the current Option instance

Annotations
@Override
setMultiValuedback to summary
public TypedOption<T> setMultiValued(boolean acceptMultipleValues)

Overrides io.vertx.core.cli.Option.setMultiValued.

Doc from io.vertx.core.cli.Option.setMultiValued.

Sets whether or not this option can receive several values.

Parameters
acceptMultipleValues:boolean

whether or not this option is multi-valued.

Returns:TypedOption<T>

the current Option instance

Annotations
@Override
setParsedAsListback to summary
public TypedOption<T> setParsedAsList(boolean isList)
setRequiredback to summary
public TypedOption<T> setRequired(boolean required)

Overrides io.vertx.core.cli.Option.setRequired.

Doc from io.vertx.core.cli.Option.setRequired.

Sets whether or not this option is mandatory.

Parameters
required:boolean

true to make this option mandatory, false otherwise

Returns:TypedOption<T>

the current Option instance

Annotations
@Override
setShortNameback to summary
public TypedOption<T> setShortName(String shortName)

Overrides io.vertx.core.cli.Option.setShortName.

Doc from io.vertx.core.cli.Option.setShortName.

Sets the short name of this option.

Parameters
shortName:String

the short name

Returns:TypedOption<T>

the current Option instance

Annotations
@Override
setSingleValuedback to summary
public TypedOption<T> setSingleValued(boolean acceptSingleValue)

Overrides io.vertx.core.cli.Option.setSingleValued.

Doc from io.vertx.core.cli.Option.setSingleValued.

Sets whether or not this option can receive a value.

Parameters
acceptSingleValue:boolean

whether or not this option is single-valued.

Returns:TypedOption<T>

the current Option instance

Annotations
@Override
setTypeback to summary
public TypedOption<T> setType(Class<T> type)