vertx / io.vertx.core.cli.converters / ValueOfBasedConverter

ValueOfBasedConverter

class ValueOfBasedConverter<T : Any> : Converter<T>

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

Properties

VALUE_OF

static val VALUE_OF: String

Functions

fromString

fun fromString(input: String): T

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

getIfEligible

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

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.