Top Description Fields Constructors Methods
io.vertx.core.cli.converters

public final Class ValueOfBasedConverter<T>

extends Object
implements Converter<T>
Class Inheritance
All Implemented Interfaces
io.vertx.core.cli.converters.Converter
Imports
java.lang.reflect.InvocationTargetException, .Method, .Modifier

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

Modifier and TypeField and Description
private final Class<T>
private final Method
public static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

the instance of T
fromString
(String
the input, can be null
input
)

Implements io.vertx.core.cli.converters.Converter.fromString.

Converts the given input to an object by using the 'valueOf' method.

public static <T> ValueOfBasedConverter<T>

Returns:

a ValueOfBasedConverter if the given class is eligible, null otherwise.
getIfEligible
(Class<T>
the class
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).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clazzback to summary
private final Class<T> clazz
methodback to summary
private final Method method
VALUE_OFback to summary
public static final String VALUE_OF

Constructor Detail

ValueOfBasedConverterback to summary
private ValueOfBasedConverter(Class<T> clazz, Method method)

Method Detail

fromStringback to summary
public T fromString(String input) throws IllegalArgumentException

Implements io.vertx.core.cli.converters.Converter.fromString.

Converts the given input to an object by using the 'valueOf' method. Notice that the method may receive a null value.

Parameters
input:String

the input, can be null

Returns:T

the instance of T

Annotations
@Override
Exceptions
IllegalArgumentException:
if the instance of T cannot be created from the input.
getIfEligibleback to summary
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:Class<T>

the class

Returns:ValueOfBasedConverter<T>

a ValueOfBasedConverter if the given class is eligible, null otherwise.

Annotations
@SuppressWarnings:unchecked