Package org.apache.commons.cli
Interface Converter<T,E extends Throwable>
- 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.
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
Modifier and TypeFieldDescriptionstatic final Converter<Class<?>,
ClassNotFoundException> Class name converter.static final Converter<Date,
ParseException> Converts to a date using the format string Form "EEE MMM dd HH:mm:ss zzz yyyy".static final Converter<?,
RuntimeException> The default converter.static final Converter<File,
NullPointerException> File name converter.static final Converter<Number,
NumberFormatException> Number converter.static final Converter<Object,
ReflectiveOperationException> Converts a class name to an instance of the class.static final Converter<Path,
InvalidPathException> Path converter.static final Converter<URL,
MalformedURLException> Creates a URL. -
Method Summary
-
Field Details
-
DEFAULT
The default converter. Does nothing. -
CLASS
Class name converter. CallsClass.forName(String)
. -
FILE
File name converter. CallsFile(String)
. -
PATH
Path converter. CallsPaths.get(java.net.URI)
. -
NUMBER
Number converter. Converts to a Double if a decimal point ('.') is in the string or a Long otherwise. -
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:
-
URL
Creates a URL. CallsURL(String)
. -
DATE
Converts to a date using the format string Form "EEE MMM dd HH:mm:ss zzz yyyy".
-
-
Method Details
-
apply
Applies the conversion function to the String argument.- Parameters:
string
- the String to convert- Returns:
- the Object from the conversion.
- Throws:
E
- on error.
-