Class ExpressionEvalMap
public final class ExpressionEvalMap extends AbstractMap<String,Object>
An immutable AbstractMap
implementation that wraps a Map<String, Object>
,
where values must be instances of String
or Expression
,
and evaluates an expression
for the provided key
from the underlying
original
Map.
Any mutating operations (put(String, Object)
, remove(Object)
etc.)
are not allowed on instances of this class. Mutation can be performed on underlying Map
if it supports it.
A ExpressionEvalMap.ExpressionEvalMapBuilder
must be used to instantiate this class
via its from(Map)
method:
ExpressionEvalMap evalMap = ExpressionEvalMap
.from(expressions)
.usingCallback(new EvaluationCallback() {
Object evaluate(Expression expression) {
// return some expression evaluation
}
})
.build();
Thread-safety depends on the original underlying Map. Objects of this class are not serializable.
- Since:
- 3.0
- Author:
- Artem Bilan, Gary Russell
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ExpressionEvalMap.ComponentsEvaluationCallback
TheExpressionEvalMap.EvaluationCallback
implementation which evaluates an expression using the providedcontext
,root
andreturnType
variables.static interface
ExpressionEvalMap.EvaluationCallback
Implementations of this interface can be provided to build 'on demandget(Object)
logic' forExpressionEvalMap
.static class
ExpressionEvalMap.ExpressionEvalMapBuilder
The builder class to instantiateExpressionEvalMap
.static interface
ExpressionEvalMap.ExpressionEvalMapComponentsBuilder
static interface
ExpressionEvalMap.ExpressionEvalMapFinalBuilder
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
Field Summary
Fields Modifier and Type Field Description static ExpressionEvalMap.EvaluationCallback
SIMPLE_CALLBACK
-
Method Summary
Modifier and Type Method Description void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<String,Object>>
entrySet()
boolean
equals(Object o)
static ExpressionEvalMap.ExpressionEvalMapBuilder
from(Map<String,?> expressions)
Object
get(Object key)
Gets thevalue
(Expression
) for the providedkey
fromoriginal
and returns the result of evaluation usingevaluationCallback
.int
hashCode()
boolean
isEmpty()
Set<String>
keySet()
Object
put(String key, Object value)
void
putAll(Map<? extends String,?> m)
Object
remove(Object key)
int
size()
String
toString()
Collection<Object>
values()
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
Method Details
-
get
Gets thevalue
(Expression
) for the providedkey
fromoriginal
and returns the result of evaluation usingevaluationCallback
. -
entrySet
-
values
-
containsKey
- Specified by:
containsKey
in interfaceMap<String,Object>
- Overrides:
containsKey
in classAbstractMap<String,Object>
-
keySet
-
isEmpty
public boolean isEmpty() -
size
public int size() -
equals
-
hashCode
public int hashCode() -
toString
- Overrides:
toString
in classAbstractMap<String,Object>
-
put
-
putAll
-
clear
public void clear() -
containsValue
- Specified by:
containsValue
in interfaceMap<String,Object>
- Overrides:
containsValue
in classAbstractMap<String,Object>
-
remove
-
from
-