Package org.graalvm.options
Class OptionType<T>
java.lang.Object
org.graalvm.options.OptionType<T>
Represents a type of an option that allows to convert string values to Java values.
- Since:
- 19.0
-
Constructor Summary
ConstructorDescriptionOptionType
(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.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.Deprecated.Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionConverts a string value, validates it, and converts it to an object of this type.Converts a string value, validates it, and converts it to an object of this type.static <T> OptionType
<T> defaultType
(Class<T> clazz) Returns the default option type for a class.static <T> OptionType
<T> defaultType
(T value) Returns the default option type for a given value.Deprecated.getName()
Returns the name of this type.toString()
void
Validates an option value and throws anIllegalArgumentException
if the value is invalid.
-
Constructor Details
-
OptionType
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:
name
- the name of the type.stringConverter
- a function that converts a string value to the option value. Can throwIllegalArgumentException
to indicate an invalid string.validator
- used for validating the option value. ThrowsIllegalArgumentException
if the value is invalid.- Since:
- 19.0
-
OptionType
Constructs a new option type with name and function that allows to convert a string to the option type.- Parameters:
name
- the name of the type.stringConverter
- a function that converts a string value to the option value. Can throwIllegalArgumentException
to indicate an invalid string.- Since:
- 19.0
-
OptionType
@Deprecated(since="19.0") public OptionType(String name, T defaultValue, Function<String, T> stringConverter, Consumer<T> validator) Deprecated.- Since:
- 19.0
-
OptionType
@Deprecated(since="19.0") public OptionType(String name, T defaultValue, Function<String, T> stringConverter) Deprecated.- Since:
- 19.0
-
-
Method Details
-
getDefaultValue
Deprecated.- Since:
- 19.0
-
getName
Returns the name of this type.- Since:
- 19.0
-
convert
Converts a string value, validates it, and converts it to an object of this type.- Throws:
IllegalArgumentException
- if the value is invalid or cannot be converted.- Since:
- 19.0
-
convert
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:
previousValue
- the previous value holded by option.nameSuffix
- the key for prefix options.- Throws:
IllegalArgumentException
- if the value is invalid or cannot be converted.- Since:
- 19.2
-
validate
Validates an option value and throws anIllegalArgumentException
if the value is invalid.- Throws:
IllegalArgumentException
- if the value is invalid or cannot be converted.- Since:
- 19.0
-
toString
-
defaultType
Returns the default option type for a given value. Returnsnull
if no default option type is available for the Java type of this value.- Since:
- 19.0
-
defaultType
Returns the default option type for a class. Returnsnull
if no default option type is available for this Java type.- Since:
- 19.0
-
OptionType(String, Function)