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>
converter
The converter to use to create the value.protected Class<T>
type
The 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 ofTypedArgument
by copying the state of anotherTypedArgument
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
ensureValidity()
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 currentArgument
is 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 currentArgument
is 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 ofTypedArgument
by 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
TypedArgument
instance
-
getConverter
public Converter<T> getConverter()
- Returns:
- the converter used to create the value,
null
if 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
TypedArgument
instance
-
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:
ensureValidity
in classArgument
-
setArgName
public TypedArgument<T> setArgName(String argName)
Description copied from class:Argument
Sets the argument name of thisArgument
.- Overrides:
setArgName
in classArgument
- Parameters:
argName
- the argument name, must not benull
- Returns:
- the current
Argument
instance
-
setDefaultValue
public TypedArgument<T> setDefaultValue(String defaultValue)
Description copied from class:Argument
Sets the default value of thisArgument
.- Overrides:
setDefaultValue
in classArgument
- Parameters:
defaultValue
- the default value- Returns:
- the current
Argument
instance
-
setDescription
public TypedArgument<T> setDescription(String description)
Description copied from class:Argument
Sets the description of theArgument
.- Overrides:
setDescription
in classArgument
- Parameters:
description
- the description- Returns:
- the current
Argument
instance
-
setHidden
public TypedArgument<T> setHidden(boolean hidden)
Description copied from class:Argument
Sets whether or not the currentArgument
is hidden.
-
setIndex
public TypedArgument<T> setIndex(int index)
Description copied from class:Argument
Sets the argument index.
-
setRequired
public TypedArgument<T> setRequired(boolean required)
Description copied from class:Argument
Sets whether or not the currentArgument
is required.- Overrides:
setRequired
in classArgument
- Parameters:
required
-true
to make this argument mandatory, {@link false} otherwise- Returns:
- the current
Argument
instance
-
setMultiValued
public TypedArgument<T> setMultiValued(boolean multiValued)
Description copied from class:Argument
Sets whether or not the argument can receive several values. Only the last argument can receive several values.- Overrides:
setMultiValued
in classArgument
- Parameters:
multiValued
-true
to mark this argument as multi-valued.- Returns:
- the current
Argument
instance
-
-