Class TypedArgument<T>

java.lang.Object
io.vertx.core.cli.Argument
io.vertx.core.cli.TypedArgument<T>

public class TypedArgument<T> extends Argument
An implementation of Argument for java specifying the type of object received by the argument. This allows converting the given raw value into the specified type.
Author:
Clement Escoffier invalid input: '<'[email protected]>
  • Field Details

    • type

      protected Class<T> type
      The type of the argument.
    • converter

      protected Converter<T> converter
      The converter to use to create the value.
  • Constructor Details

    • TypedArgument

      public TypedArgument(TypedArgument<T> arg)
      Creates a new instance of TypedArgument by copying the state of another TypedArgument.
      Parameters:
      arg - the copied argument
    • TypedArgument

      public TypedArgument()
      Creates an empty instance of TypedArgument.
  • Method Details

    • getType

      public Class<T> getType()
      Returns:
      the argument type, cannot be null for valid argument.
    • 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 a IllegalArgumentException.
      Overrides:
      ensureValidity in class Argument
    • setArgName

      public TypedArgument<T> setArgName(String argName)
      Description copied from class: Argument
      Sets the argument name of this Argument.
      Overrides:
      setArgName in class Argument
      Parameters:
      argName - the argument name, must not be null
      Returns:
      the current Argument instance
    • setDefaultValue

      public TypedArgument<T> setDefaultValue(String defaultValue)
      Description copied from class: Argument
      Sets the default value of this Argument.
      Overrides:
      setDefaultValue in class Argument
      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 the Argument.
      Overrides:
      setDescription in class Argument
      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 current Argument is hidden.
      Overrides:
      setHidden in class Argument
      Parameters:
      hidden - enables or disables the visibility of this Argument
      Returns:
      the current Argument instance
    • setIndex

      public TypedArgument<T> setIndex(int index)
      Description copied from class: Argument
      Sets the argument index.
      Overrides:
      setIndex in class Argument
      Parameters:
      index - the index, must not be negative
      Returns:
      the current Argument instance
    • setRequired

      public TypedArgument<T> setRequired(boolean required)
      Description copied from class: Argument
      Sets whether or not the current Argument is required.
      Overrides:
      setRequired in class Argument
      Parameters:
      required - true to make this argument mandatory,
      invalid @link
      {@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 class Argument
      Parameters:
      multiValued - true to mark this argument as multi-valued.
      Returns:
      the current Argument instance