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.
| Modifier and Type | Class and Description |
|---|---|
static class |
ExpressionEvalMap.ComponentsEvaluationCallback
The
ExpressionEvalMap.EvaluationCallback implementation which evaluates an expression using
the provided context, root and returnType variables. |
static interface |
ExpressionEvalMap.EvaluationCallback
Implementations of this interface can be provided to build 'on demand
get(Object) logic'
for ExpressionEvalMap. |
static class |
ExpressionEvalMap.ExpressionEvalMapBuilder
The builder class to instantiate
ExpressionEvalMap. |
static interface |
ExpressionEvalMap.ExpressionEvalMapComponentsBuilder |
static interface |
ExpressionEvalMap.ExpressionEvalMapFinalBuilder |
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Modifier and Type | Field and Description |
|---|---|
static ExpressionEvalMap.EvaluationCallback |
SIMPLE_CALLBACK |
| Modifier and Type | Method and 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 the
value(Expression) for the provided key
from original and returns the result of evaluation using evaluationCallback. |
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() |
clonefinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic static final ExpressionEvalMap.EvaluationCallback SIMPLE_CALLBACK
@Nullable public Object get(Object key)
value(Expression) for the provided key
from original and returns the result of evaluation using evaluationCallback.public Collection<Object> values()
public boolean containsKey(Object key)
containsKey in interface Map<String,Object>containsKey in class AbstractMap<String,Object>public boolean isEmpty()
public int size()
public boolean equals(Object o)
public int hashCode()
public String toString()
toString in class AbstractMap<String,Object>public void clear()
public boolean containsValue(Object value)
containsValue in interface Map<String,Object>containsValue in class AbstractMap<String,Object>public static ExpressionEvalMap.ExpressionEvalMapBuilder from(Map<String,?> expressions)