Package io.vertx.core.cli.converters

## Class ValueOfBasedConverter<T>

- java.lang.Object
- - io.vertx.core.cli.converters.ValueOfBasedConverter<T>

- All Implemented Interfaces:
    `Converter<T>`

      public final class ValueOfBasedConverter<T>
      extends Object
      implements Converter<T>

  This 'default' converter tries to create objects using a static 'valueOf' method taking a single String argument. This converter is particularly convenient to for enumeration and primitive types.
  Author:
    Clement Escoffier

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static String` | `VALUE_OF` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `T` | `fromString​(String input)` | Converts the given input to an object by using the 'valueOf' method.
    `static <T> ValueOfBasedConverter<T>` | `getIfEligible​(Class<T> clazz)` | Checks whether the given class can be used by the `ValueOfBasedConverter` (i.e.

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

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

- - ### Field Detail

    - #### VALUE_OF

          public static final String VALUE_OF

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getIfEligible

          public static <T> ValueOfBasedConverter<T> getIfEligible​(Class<T> clazz)

      Checks whether the given class can be used by the `ValueOfBasedConverter` (i.e. has a static 'valueOf' method taking a single String as argument). If so, creates a new instance of converter for this type.
      Parameters:
        `clazz` - the class
      Returns:
        a `ValueOfBasedConverter` if the given class is eligible, null otherwise.

    - #### fromString

          public T fromString​(String input)
                       throws IllegalArgumentException

      Converts the given input to an object by using the 'valueOf' method. Notice that the method may receive a null value.
      Specified by:
        `fromString` in interface `Converter<T>`
      Parameters:
        `input` - the input, can be null
      Returns:
        the instance of T
      Throws:
        `IllegalArgumentException` - if the instance of T cannot be created from the input.