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

public final Class ConstructorBasedConverter<T>

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

This 'default' converter tries to create objects using a constructor taking a single String argument. Be aware that implementation must also handle the case where the input is null.
Author
Clement Escoffier

Field Summary

Modifier and TypeField and Description
private final Constructor<T>

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 constructor approach.

public static <T> ConstructorBasedConverter<T>

Returns:

a ConstructorBasedConverter if the given class is eligible, null otherwise.
getIfEligible
(Class<T>
the class
clazz
)

Checks whether the given class can be used by the ConstructorBasedConverter (i.e. has a constructor taking a single String as argument).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

constructorback to summary
private final Constructor<T> constructor

Constructor Detail

ConstructorBasedConverterback to summary
private ConstructorBasedConverter(Constructor<T> constructor)

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 constructor approach. Notice that the constructor must expect receiving 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> ConstructorBasedConverter<T> getIfEligible(Class<T> clazz)

Checks whether the given class can be used by the ConstructorBasedConverter (i.e. has a constructor taking a single String as argument). If so, creates a new instance of converter for this type.

Parameters
clazz:Class<T>

the class

Returns:ConstructorBasedConverter<T>

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