Package org.apache.commons.cli

# Interface Converter<T,E extends Exception>

Type Parameters:
  `T` - The return type for the function.
  `E` - The kind of thrown exception or error.

Functional Interface:
  This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Converter<T,E extends Exception>
The definition of the functional interface to call when doing a conversion. Like `Function<String,T>` but can throw an Exception.

Since:
  1.7.0

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Converter<Class<?>,ClassNotFoundException>`
  `CLASS`
  Class name converter.
  `static final Converter<Date,ParseException>`
  `DATE`
  Converts to a date using the format string Form "EEE MMM dd HH:mm:ss zzz yyyy".
  `static final Converter<?,RuntimeException>`
  `DEFAULT`
  The default converter.
  `static final Converter<File,NullPointerException>`
  `FILE`
  File name converter.
  `static final Converter<Number,NumberFormatException>`
  `NUMBER`
  Number converter.
  `static final Converter<Object,ReflectiveOperationException>`
  `OBJECT`
  Converts a class name to an instance of the class.
  `static final Converter<Path,InvalidPathException>`
  `PATH`
  Path converter.
  `static final Converter<URL,MalformedURLException>`
  `URL`
  Creates a URL.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `T`
  `apply(String string)`
  Applies the conversion function to the String argument.

- ## Field Details

  - ### DEFAULT

    static final Converter<?,RuntimeException> DEFAULT
    The default converter. Does nothing.

  - ### CLASS

    static final Converter<Class<?>,ClassNotFoundException> CLASS
    Class name converter. Calls `Class.forName(String)`.

  - ### FILE

    static final Converter<File,NullPointerException> FILE
    File name converter. Calls `File(String)`.

  - ### PATH

    static final Converter<Path,InvalidPathException> PATH
    Path converter. Calls `Paths.get(java.net.URI)`.

  - ### NUMBER

    static final Converter<Number,NumberFormatException> NUMBER
    Number converter. Converts to a Double if a decimal point ('.') is in the string or a Long otherwise.

  - ### OBJECT

    static final Converter<Object,ReflectiveOperationException> OBJECT
    Converts a class name to an instance of the class. Uses the Class converter to find the class and then call the default constructor.
    See Also:
      - `CLASS`

  - ### URL

    static final Converter<URL,MalformedURLException> URL
    Creates a URL. Calls `URL(String)`.

  - ### DATE

    static final Converter<Date,ParseException> DATE
    Converts to a date using the format string Form "EEE MMM dd HH:mm:ss zzz yyyy".

- ## Method Details

  - ### apply

    T apply(String string) throws E
    Applies the conversion function to the String argument.
    Parameters:
      `string` - the String to convert
    Returns:
      the Object from the conversion.
    Throws:
      `E` - on error.