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

OptionKey

Javasealed classin org.graalvm.optionssince 19.0

public sealed class OptionKey<T> permits ConstantOptionKey
Inheritance
  1. Object
  2. OptionKey
Permitted subtypes

Represents the option key for an option specification.

Constructors2

OptionKey(T)

OptionKey

since 19.0
public OptionKey(T defaultValue)

Constructs a new option key given a default value. Throws IllegalArgumentException if no default OptionType could be resolved for the given type. The default value must not be null.

Parameters

defaultValueT
No description.
OptionKey(T, OptionType<T>)

OptionKey

since 19.0
public OptionKey(T defaultValue, OptionType<T> type)

Constructs a new option key given a default value and option key.

Parameters

defaultValueT
No description.
typeOptionType<T>
No description.

Methods5

static OptionKey<OptionMap<V>> mapOf(Class<V>)

mapOf

staticsince 19.2
public static <V> OptionKey<OptionMap<V>> mapOf(Class<V> valueClass)

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. See OptionMap. 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 the mylang.Properties prefix.

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"); // null

Throws IllegalArgumentException if no default OptionType could be resolved for the value type.

Parameters

valueClassClass<V>
No description.

Returns

OptionKey<OptionMap<V>>
No description.
OptionType<T> getType()

getType

since 19.0
public OptionType<T> getType()

Returns the option type of this key.

Returns

OptionType<T>
No description.
T getDefaultValue()

getDefaultValue

since 19.0
public T getDefaultValue()

Returns the default value for this option.

Returns

T
No description.
T getValue(OptionValues)

getValue

since 19.0
public T getValue(OptionValues values)

Returns the value of this key given the values.

Parameters

valuesOptionValues
No description.

Returns

T
No description.
boolean hasBeenSet(OptionValues)

hasBeenSet

since 19.0
public boolean hasBeenSet(OptionValues values)

Returns true if a value for this key has been set for the given option values or false if no value has been set.

Parameters

valuesOptionValues
No description.

Returns

boolean
No description.

Inherited members