Class OptionType<T>

java.lang.Object
org.graalvm.options.OptionType<T>

public final class OptionType<T> extends Object
Represents a type of an option that allows to convert string values to Java values.
Since:
19.0
  • Constructor Details

  • Method Details

    • getDefaultValue

      @Deprecated(since="19.0") public T getDefaultValue()
      Deprecated.
      Since:
      19.0
    • getName

      public String getName()
      Returns the name of this type.
      Since:
      19.0
    • convert

      public T convert(String value)
      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

      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:
      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

      public void validate(T value)
      Validates an option value and throws an IllegalArgumentException if the value is invalid.
      Throws:
      IllegalArgumentException - if the value is invalid or cannot be converted.
      Since:
      19.0
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Since:
      19.0
    • defaultType

      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.
      Since:
      19.0
    • defaultType

      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.
      Since:
      19.0