Package io.vertx.core.cli

## 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

- - ### 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 of `TypedArgument`.
    `TypedArgument​(TypedArgument<T> arg)` | Creates a new instance of `TypedArgument` by copying the state of another `TypedArgument`.

  - ### 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 this `Argument`.
    `TypedArgument<T>` | `setConverter​(Converter<T> converter)` | Sets the converter used to create the value.
    `TypedArgument<T>` | `setDefaultValue​(String defaultValue)` | Sets the default value of this `Argument`.
    `TypedArgument<T>` | `setDescription​(String description)` | Sets the description of the `Argument`.
    `TypedArgument<T>` | `setHidden​(boolean hidden)` | Sets whether or not the current `Argument` 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 current `Argument` 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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### type

          protected Class<T> type

      The type of the argument.

    - #### converter

          protected Converter<T> converter

      The converter to use to create the value.

  - ### Constructor Detail

    - #### 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 Detail

    - #### 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, {@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