io.vertx.core.cli

## Class TypedOption<T>

- java.lang.Object
- - io.vertx.core.cli.Option
  - - io.vertx.core.cli.TypedOption<T>

-     public class TypedOption<T>
      extends Option

  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

    Fields
    Modifier and Type | Field 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.

    - ### Fields inherited from class io.vertx.core.cli.Option

      `argName, choices, DEFAULT_ARG_NAME, defaultValue, description, flag, help, hidden, longName, multiValued, NO_NAME, required, shortName, singleValued`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TypedOption()` Creates an empty instance of `TypedOption`.
    `TypedOption(TypedOption<T> option)` Creates an instance of `TypedOption` by copying the state of another `TypedOption`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `TypedOption<T>` | `addChoice(String choice)` Adds a choice to the list of values accepted by this option.
    `void` | `ensureValidity()` Checks whether or not the option is valid.
    `Converter<T>` | `getConverter()`
    `String` | `getListSeparator()`
    `Class<T>` | `getType()`
    `boolean` | `isParsedAsList()`
    `TypedOption<T>` | `setArgName(String argName)` Sets te arg name for this option.
    `TypedOption<T>` | `setChoices(Set<String> choices)` Sets the list of values accepted by this option.
    `TypedOption<T>` | `setConverter(Converter<T> converter)`
    `TypedOption<T>` | `setDefaultValue(String defaultValue)` Sets the default value of this option
    `TypedOption<T>` | `setDescription(String description)` Sets te description of this option.
    `TypedOption<T>` | `setFlag(boolean flag)` Configures the current `Option` to be a flag.
    `TypedOption<T>` | `setHidden(boolean hidden)` Sets whether or not this option should be hidden
    `TypedOption<T>` | `setListSeparator(String listSeparator)`
    `TypedOption<T>` | `setLongName(String longName)` Sets the long name of this option.
    `TypedOption<T>` | `setMultiValued(boolean acceptMultipleValues)` Sets whether or not this option can receive several values.
    `TypedOption<T>` | `setParsedAsList(boolean isList)`
    `TypedOption<T>` | `setRequired(boolean required)` Sets whether or not this option is mandatory.
    `TypedOption<T>` | `setShortName(String shortName)` Sets the short name of this option.
    `TypedOption<T>` | `setSingleValued(boolean acceptSingleValue)` Sets whether or not this option can receive a value.
    `TypedOption<T>` | `setType(Class<T> type)`

    - ### Methods inherited from class io.vertx.core.cli.Option

      `acceptValue, getArgName, getChoices, getDefaultValue, getDescription, getLongName, getName, getShortName, isFlag, isHelp, isHidden, isMultiValued, isRequired, isSingleValued, setHelp, 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 option.

    - #### parsedAsList

          protected boolean parsedAsList

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

    - #### listSeparator

          protected String listSeparator

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

    - #### converter

          protected Converter<T> converter

      the converter to create the value.

  - ### Constructor Detail

    - #### TypedOption

          public TypedOption()

      Creates an empty instance of `TypedOption`.

    - #### TypedOption

          public TypedOption(TypedOption<T> option)

      Creates an instance of `TypedOption` by copying the state of another `TypedOption`
      Parameters:
        `option` - the copied option

  - ### Method Detail

    - #### setMultiValued

          public TypedOption<T> setMultiValued(boolean acceptMultipleValues)

      Description copied from class: `Option`
      Sets whether or not this option can receive several values.
      Overrides:
        `setMultiValued` in class `Option`
      Parameters:
        `acceptMultipleValues` - whether or not this option is multi-valued.
      Returns:
        the current `Option` instance

    - #### setSingleValued

          public TypedOption<T> setSingleValued(boolean acceptSingleValue)

      Description copied from class: `Option`
      Sets whether or not this option can receive a value.
      Overrides:
        `setSingleValued` in class `Option`
      Parameters:
        `acceptSingleValue` - whether or not this option is single-valued.
      Returns:
        the current `Option` instance

    - #### setArgName

          public TypedOption<T> setArgName(String argName)

      Description copied from class: `Option`
      Sets te arg name for this option.
      Overrides:
        `setArgName` in class `Option`
      Parameters:
        `argName` - the arg name, must not be `null`
      Returns:
        the current `Option` instance

    - #### setDefaultValue

          public TypedOption<T> setDefaultValue(String defaultValue)

      Description copied from class: `Option`
      Sets the default value of this option
      Overrides:
        `setDefaultValue` in class `Option`
      Parameters:
        `defaultValue` - the default value
      Returns:
        the current `Option` instance

    - #### setDescription

          public TypedOption<T> setDescription(String description)

      Description copied from class: `Option`
      Sets te description of this option.
      Overrides:
        `setDescription` in class `Option`
      Parameters:
        `description` - the description
      Returns:
        the current `Option` instance

    - #### setFlag

          public TypedOption<T> setFlag(boolean flag)

      Description copied from class: `Option`
      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)

      `
      Overrides:
        `setFlag` in class `Option`
      Parameters:
        `flag` - whether or not the option is a flag.
      Returns:
        the current `Option`

    - #### setHidden

          public TypedOption<T> setHidden(boolean hidden)

      Description copied from class: `Option`
      Sets whether or not this option should be hidden
      Overrides:
        `setHidden` in class `Option`
      Parameters:
        `hidden` - `true` to make this option hidden, `false` otherwise
      Returns:
        the current `Option` instance

    - #### setLongName

          public TypedOption<T> setLongName(String longName)

      Description copied from class: `Option`
      Sets the long name of this option.
      Overrides:
        `setLongName` in class `Option`
      Parameters:
        `longName` - the long name
      Returns:
        the current `Option` instance

    - #### setRequired

          public TypedOption<T> setRequired(boolean required)

      Description copied from class: `Option`
      Sets whether or not this option is mandatory.
      Overrides:
        `setRequired` in class `Option`
      Parameters:
        `required` - `true` to make this option mandatory, `false` otherwise
      Returns:
        the current `Option` instance

    - #### setShortName

          public TypedOption<T> setShortName(String shortName)

      Description copied from class: `Option`
      Sets the short name of this option.
      Overrides:
        `setShortName` in class `Option`
      Parameters:
        `shortName` - the short name
      Returns:
        the current `Option` instance

    - #### getType

          public Class<T> getType()

    - #### setType

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

    - #### isParsedAsList

          public boolean isParsedAsList()

    - #### setParsedAsList

          public TypedOption<T> setParsedAsList(boolean isList)

    - #### getListSeparator

          public String getListSeparator()

    - #### setListSeparator

          public TypedOption<T> setListSeparator(String listSeparator)

    - #### getConverter

          public Converter<T> getConverter()

    - #### setConverter

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

    - #### ensureValidity

          public void ensureValidity()

      Description copied from class: `Option`
      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`.
      Overrides:
        `ensureValidity` in class `Option`

    - #### setChoices

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

      Description copied from class: `Option`
      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.
      Overrides:
        `setChoices` in class `Option`
      Parameters:
        `choices` - the choices
      Returns:
        the current `Option`

    - #### addChoice

          public TypedOption<T> addChoice(String choice)

      Description copied from class: `Option`
      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.
      Overrides:
        `addChoice` in class `Option`
      Parameters:
        `choice` - the choice
      Returns:
        the current `Option`

Copyright © 2022 Eclipse. All rights reserved.