Elide GraalVM25.6.0-elide.4
All types
Versions and modules

OptionType

Javaclassin org.graalvm.optionssince 19.0

public final class OptionType<T>
Inheritance
  1. Object
  2. OptionType

Represents a type of an option that allows to convert string values to Java values.

Constructors4

OptionType(String, Function<String, T>, Consumer<T>)

OptionType

since 19.0
public OptionType(String name, Function<String, T> stringConverter, Consumer<T> validator)

Constructs a new option type with name and function that allows to convert a string to the option type and validator of the option values.

Parameters

nameString
the name of the type.
stringConverterFunction<String, T>
a function that converts a string value to the option value. Can throw IllegalArgumentException to indicate an invalid string.
validatorConsumer<T>
used for validating the option value. Throws IllegalArgumentException if the value is invalid.
OptionType(String, Function<String, T>)

OptionType

since 19.0
public OptionType(String name, Function<String, T> stringConverter)

Constructs a new option type with name and function that allows to convert a string to the option type.

Parameters

nameString
the name of the type.
stringConverterFunction<String, T>
a function that converts a string value to the option value. Can throw IllegalArgumentException to indicate an invalid string.
OptionType(String, T, Function<String, T>, Consumer<T>)No description.deprecated

OptionType

since 19.0
@Deprecated(since = "19.0")
public OptionType(
    String name,
    T defaultValue,
    Function<String, T> stringConverter,
    Consumer<T> validator
)

No description.

Parameters

nameString
No description.
defaultValueT
No description.
stringConverterFunction<String, T>
No description.
validatorConsumer<T>
No description.
OptionType(String, T, Function<String, T>)No description.deprecated

OptionType

since 19.0
@Deprecated(since = "19.0")
public OptionType(String name, T defaultValue, Function<String, T> stringConverter)

Deprecated since 19.0

Use OptionType(String, Function)

No description.

Parameters

nameString
No description.
defaultValueT
No description.
stringConverterFunction<String, T>
No description.

Methods8

T getDefaultValue()No description.deprecated

getDefaultValue

since 19.0
@Deprecated(since = "19.0")
public T getDefaultValue()

Deprecated since 19.0

No description.

Returns

T
No description.
String getName()

getName

since 19.0
public String getName()

Returns the name of this type.

Returns

String
No description.
T convert(String)

convert

since 19.0
public T convert(String value)

Converts a string value, validates it, and converts it to an object of this type.

Parameters

valueString
No description.

Returns

T
No description.

Throws

IllegalArgumentExceptionunchecked
if the value is invalid or cannot be converted.
T convert(Object, String, String)

convert

since 19.2
public T convert(Object previousValue, String nameSuffix, String value)

Converts a string value, validates it, and converts it to an object of this type. For option maps includes the previous map stored for the option and the key.

Parameters

previousValueObject
the previous value holded by option.
nameSuffixString
the key for prefix options.
valueString
No description.

Returns

T
No description.

Throws

IllegalArgumentExceptionunchecked
if the value is invalid or cannot be converted.
void validate(T)

validate

since 19.0
public void validate(T value)

Validates an option value and throws an IllegalArgumentException if the value is invalid.

Parameters

valueT
No description.

Throws

IllegalArgumentExceptionunchecked
if the value is invalid or cannot be converted.
String toString()Described in toString().

toString

since 19.0
public String toString()

Described in toString().

Returns

String
No description.
static OptionType<T> defaultType(T)

defaultType

staticsince 19.0
public static <T> OptionType<T> defaultType(T value)

Returns the default option type for a given value. Returns null if no default option type is available for the Java type of this value.

Parameters

valueT
No description.

Returns

OptionType<T>
No description.
static OptionType<T> defaultType(Class<T>)

defaultType

staticsince 19.0
public static <T> OptionType<T> defaultType(Class<T> clazz)

Returns the default option type for a class. Returns null if no default option type is available for this Java type.

Parameters

clazzClass<T>
No description.

Returns

OptionType<T>
No description.

Inherited members