Package io.vertx.core.cli
Class TypedArgument<T>
- java.lang.Object
-
- io.vertx.core.cli.Argument
-
- io.vertx.core.cli.TypedArgument<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected Converter<T>converterThe converter to use to create the value.protected Class<T>typeThe type of the argument.-
Fields inherited from class io.vertx.core.cli.Argument
argName, DEFAULT_ARG_NAME, defaultValue, description, hidden, index, multiValued, required
-
-
Constructor Summary
Constructors Constructor Description TypedArgument()Creates an empty instance ofTypedArgument.TypedArgument(TypedArgument<T> arg)Creates a new instance ofTypedArgumentby copying the state of anotherTypedArgument.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidensureValidity()Checks whether or not the argument configuration is valid.Converter<T>getConverter()Class<T>getType()TypedArgument<T>setArgName(String argName)Sets the argument name of thisArgument.TypedArgument<T>setConverter(Converter<T> converter)Sets the converter used to create the value.TypedArgument<T>setDefaultValue(String defaultValue)Sets the default value of thisArgument.TypedArgument<T>setDescription(String description)Sets the description of theArgument.TypedArgument<T>setHidden(boolean hidden)Sets whether or not the currentArgumentis hidden.TypedArgument<T>setIndex(int index)Sets the argument index.TypedArgument<T>setMultiValued(boolean multiValued)Sets whether or not the argument can receive several values.TypedArgument<T>setRequired(boolean required)Sets whether or not the currentArgumentis required.TypedArgument<T>setType(Class<T> type)Sets the argument type.-
Methods inherited from class io.vertx.core.cli.Argument
getArgName, getDefaultValue, getDescription, getIndex, isHidden, isMultiValued, isRequired, toJson
-
-
-
-
Constructor Detail
-
TypedArgument
public TypedArgument(TypedArgument<T> arg)
Creates a new instance ofTypedArgumentby copying the state of anotherTypedArgument.- Parameters:
arg- the copied argument
-
TypedArgument
public TypedArgument()
Creates an empty instance ofTypedArgument.
-
-
Method Detail
-
setType
public TypedArgument<T> setType(Class<T> type)
Sets the argument type.- Parameters:
type- the type- Returns:
- the current
TypedArgumentinstance
-
getConverter
public Converter<T> getConverter()
- Returns:
- the converter used to create the value,
nullif not set
-
setConverter
public TypedArgument<T> setConverter(Converter<T> converter)
Sets the converter used to create the value.- Parameters:
converter- the converter- Returns:
- the current
TypedArgumentinstance
-
ensureValidity
public void ensureValidity()
Checks whether or not the argument configuration is valid. In addition of the check made by the parent class it ensures that the type is set. If the configuration is not valid, this method throws aIllegalArgumentException.- Overrides:
ensureValidityin classArgument
-
setArgName
public TypedArgument<T> setArgName(String argName)
Description copied from class:ArgumentSets the argument name of thisArgument.- Overrides:
setArgNamein classArgument- Parameters:
argName- the argument name, must not benull- Returns:
- the current
Argumentinstance
-
setDefaultValue
public TypedArgument<T> setDefaultValue(String defaultValue)
Description copied from class:ArgumentSets the default value of thisArgument.- Overrides:
setDefaultValuein classArgument- Parameters:
defaultValue- the default value- Returns:
- the current
Argumentinstance
-
setDescription
public TypedArgument<T> setDescription(String description)
Description copied from class:ArgumentSets the description of theArgument.- Overrides:
setDescriptionin classArgument- Parameters:
description- the description- Returns:
- the current
Argumentinstance
-
setHidden
public TypedArgument<T> setHidden(boolean hidden)
Description copied from class:ArgumentSets whether or not the currentArgumentis hidden.
-
setIndex
public TypedArgument<T> setIndex(int index)
Description copied from class:ArgumentSets the argument index.
-
setRequired
public TypedArgument<T> setRequired(boolean required)
Description copied from class:ArgumentSets whether or not the currentArgumentis required.- Overrides:
setRequiredin classArgument- Parameters:
required-trueto make this argument mandatory, {@link false} otherwise- Returns:
- the current
Argumentinstance
-
setMultiValued
public TypedArgument<T> setMultiValued(boolean multiValued)
Description copied from class:ArgumentSets whether or not the argument can receive several values. Only the last argument can receive several values.- Overrides:
setMultiValuedin classArgument- Parameters:
multiValued-trueto mark this argument as multi-valued.- Returns:
- the current
Argumentinstance
-
-