Class OptionKey<T>
java.lang.Object
org.graalvm.options.OptionKey<T>
Represents the option key for an option specification.
- Since:
- 19.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the default value for this option.getType()Returns the option type of this key.getValue(OptionValues values) Returns the value of this key given thevalues.booleanhasBeenSet(OptionValues values) Returnstrueif a value for this key has been set for the given option values orfalseif no value has been set.Constructs a new option key to group/accumulate options with common prefixes.
-
Constructor Details
-
OptionKey
Constructs a new option key given a default value. ThrowsIllegalArgumentExceptionif no defaultOptionTypecould beresolvedfor the given type. The default value must not benull.- Since:
- 19.0
-
OptionKey
Constructs a new option key given a default value and option key.- Since:
- 19.0
-
-
Method Details
-
mapOf
Constructs a new option key to group/accumulate options with common prefixes. This type of options allow to collect key=value pairs whose keys are unknown beforehand e.g. user defined properties. SeeOptionMap. Example usage:@Option.Group("mylang") public class MiscOptions { @Option(help = "User-defined properties", category = OptionCategory.USER) // public static final OptionKey<OptionMap<String>> Properties = OptionKey.mapOf(String.class); ... }Properties can be set using themylang.Propertiesprefix.Context context = Context.newBuilder() // .option("mylang.Properties.key", "value") // .option("mylang.Properties.user.name", "guest") // .build();The option map can be consumed as follows:OptionMap<String> properties = getOptions().get(MiscOptions.Properties); properties.get("key"); // value properties.get("user.name"); // guest properties.get("undefined"); // nullThrowsIllegalArgumentExceptionif no defaultOptionTypecould beresolvedfor the value type.- Since:
- 19.2
-
getType
-
getDefaultValue
-
getValue
-
hasBeenSet
Returnstrueif a value for this key has been set for the given option values orfalseif no value has been set.- Since:
- 19.0
-