Class ConstructorBasedConverter<T>
java.lang.Object
io.vertx.core.cli.converters.ConstructorBasedConverter<T>
- All Implemented Interfaces:
Converter<T>
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 invalid input: '<'[email protected]>
-
Method Summary
Modifier and TypeMethodDescriptionfromString(String input) Converts the given input to an object by using the constructor approach.static <T> ConstructorBasedConverter<T> getIfEligible(Class<T> clazz) Checks whether the given class can be used by theConstructorBasedConverter(i.e. has a constructor taking a single String as argument).
-
Method Details
-
getIfEligible
Checks whether the given class can be used by theConstructorBasedConverter(i.e. has a constructor taking a single String as argument). If so, creates a new instance of converter for this type.- Parameters:
clazz- the class- Returns:
- a
ConstructorBasedConverterif the given class is eligible, null otherwise.
-
fromString
Converts the given input to an object by using the constructor approach. Notice that the constructor must expect receiving a null value.- Specified by:
fromStringin interfaceConverter<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.
-