public class DefaultVariableContext extends Object implements VariableContext
VariableContext
.Constructor and Description |
---|
DefaultVariableContext() |
Modifier and Type | Method and Description |
---|---|
void |
addVariableResolver(VariableResolver resolver)
Adds a variable resolver to this variable context.
|
Object |
getValue(String name)
Returns the value currently set for the variable given by its name, or
null if no such variable exists.
|
<V> V |
getValue(String name,
ValueConverter<V> converter)
Returns the value of the variable given by name and converts it into the
target type
<V> using the given converter. |
void |
removeVariableResolver(VariableResolver resolver)
Removes the specified variable resolver if it exists and does nothing
otherwise.
|
String |
toString() |
public DefaultVariableContext()
public void addVariableResolver(VariableResolver resolver)
VariableContext
addVariableResolver
in interface VariableContext
resolver
- the resolver to addpublic void removeVariableResolver(VariableResolver resolver)
VariableContext
removeVariableResolver
in interface VariableContext
resolver
- the resolver to removepublic Object getValue(String name)
VariableResolver
getValue
in interface VariableResolver
name
- the variable namepublic <V> V getValue(String name, ValueConverter<V> converter) throws IllegalArgumentException
VariableContext
<V>
using the given converter. Returns null if no
such variable exists. An exception is thrown if the conversion fails, or
which is indicated by a null value returned by the converter for a
non-null input value.getValue
in interface VariableContext
V
- the target value typename
- the variable nameconverter
- a converter suitable to convert values into the target type
<V>
IllegalArgumentException
- if the value conversion fails, that is, if the converter
returns null for the non-null input valueCopyright © 2024. All rights reserved.