vertx / io.vertx.core.cli.converters / ConstructorBasedConverter

ConstructorBasedConverter

class ConstructorBasedConverter<T : Any> : 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

Functions

fromString

fun fromString(input: String): T

Converts the given input to an object by using the constructor approach. Notice that the constructor must expect receiving a null value.

getIfEligible

static fun <T : Any> getIfEligible(clazz: Class<T>): ConstructorBasedConverter<T>

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.