ColorConfigKey
, DashConfigKey
, ShaderConfigKey
public abstract class ChoiceConfigKey<T> extends ConfigKey<T>
Constructor | Description |
---|---|
ChoiceConfigKey(ConfigMeta meta,
java.lang.Class<T> clazz,
T dflt,
boolean nullPermitted) |
Constructor.
|
Modifier and Type | Method | Description |
---|---|---|
void |
addOption(T option) |
Adds an option to the permitted list.
|
abstract T |
decodeString(java.lang.String sval) |
Takes a string, and attempts to turn it into an object which may
be a value for this key.
|
java.util.Map<java.lang.String,T> |
getOptionMap() |
Returns a mutable map giving the currently available known options
and their string values.
|
abstract java.lang.String |
stringifyValue(T value) |
Takes an object which may be a value of this key,
and attempts to turn it into a string for reporting purposes.
|
T |
stringToValue(java.lang.String sval) |
Decodes a string value to the value type of this key.
|
java.lang.String |
valueToString(T value) |
Reports a value as a string.
|
cast, createSpecifier, getDefaultValue, getMeta, getValueClass, toString
public ChoiceConfigKey(ConfigMeta meta, java.lang.Class<T> clazz, T dflt, boolean nullPermitted)
meta
- metadataclazz
- value classdflt
- default valuenullPermitted
- true iff null is a permitted valuepublic void addOption(T option)
stringifyValue(T)
method,
which must return a non-null value.
For more flexibility, you can manipulate the return value of
getOptionMap()
directly.
option
- option to addpublic java.util.Map<java.lang.String,T> getOptionMap()
public abstract T decodeString(java.lang.String sval)
This method should be the opposite of stringifyValue(T)
,
but does not need to be consistent with
stringToValue
or
valueToString
.
sval
- string representationpublic abstract java.lang.String stringifyValue(T value)
This method should if possible
be the opposite of decodeString(java.lang.String)
,
but does not need to be consistent with
stringToValue
or
valueToString
.
If no round-trippable value is available, null should be returned.
value
- typed objectpublic T stringToValue(java.lang.String sval) throws ConfigException
ConfigKey
stringToValue
in class ConfigKey<T>
sval
- string representation of valueConfigException
public java.lang.String valueToString(T value)
ConfigKey
stringToValue(valueToString(v)).equals(v)
.
A null value, if permitted, should be represented as an empty string.valueToString
in class ConfigKey<T>
value
- possible value associated with this keyCopyright © 2018 Central Laboratory of the Research Councils. All Rights Reserved.