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
ConstructorsConstructorDescriptionOptionType(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()voidValidates an option value and throws anIllegalArgumentExceptionif 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 throwIllegalArgumentExceptionto indicate an invalid string.validator- used for validating the option value. ThrowsIllegalArgumentExceptionif 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 throwIllegalArgumentExceptionto indicate an invalid string.- Since:
- 19.0
-
OptionType
-
OptionType
-
-
Method Details
-
getDefaultValue
-
getName
-
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 anIllegalArgumentExceptionif 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. Returnsnullif 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. Returnsnullif no default option type is available for this Java type.- Since:
- 19.0
-
OptionType(String, Function)