@ConsumerType public class LazyBindings extends HashMap<String,Object> implements Bindings
The LazyBindings wraps another map and dynamically provides entries for the wrapped map through a map of LazyBindings.Suppliers.
When get(Object) is called with a key that's not present in the wrapped map, then the LazyBindings.Suppliers map
will be queried and, if an entry exists for that key, the LazyBindings.Supplier-generated value will be used to populate the
wrapped map.
While the keySet() and containsKey(Object) will also check the keys present in the LazyBindings.Suppliers map,
all other methods (e.g. values(), HashMap.containsValue(Object)) will only deal with the contents of the wrapped map.
entrySet() will however return a merged view of both the LazyBindings.Suppliers and the wrapped map, so that copies to
other LazyBindings maps preserve the functionality of having lazily-evaluated bindings.
This class does not provide any thread-safety guarantees. If this Bindings map needs to be used in a concurrent
setup it's the responsibility of the caller to synchronize access. The simplest way would be to wrap it through Collections.synchronizedMap(Map).
| Modifier and Type | Class and Description |
|---|---|
static interface |
LazyBindings.Supplier
This marker interface should be used for suppliers which should be unwrapped when used as values stored in a
LazyBindings map. |
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
LazyBindings() |
LazyBindings(Map<String,LazyBindings.Supplier> suppliers) |
LazyBindings(Map<String,LazyBindings.Supplier> suppliers,
Map<String,Object> wrapped) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
containsKey(Object key) |
@NotNull Set<Map.Entry<String,Object>> |
entrySet() |
boolean |
equals(Object o) |
Object |
get(Object key) |
Object |
getOrDefault(Object key,
Object defaultValue) |
int |
hashCode() |
boolean |
isEmpty() |
@NotNull Set<String> |
keySet() |
Object |
put(String key,
Object value) |
void |
putAll(Map<? extends String,?> toMerge) |
Object |
remove(Object key) |
int |
size() |
@NotNull Collection<Object> |
values() |
clone, compute, computeIfAbsent, computeIfPresent, containsValue, forEach, merge, putIfAbsent, remove, replace, replace, replaceAlltoStringcompute, computeIfAbsent, computeIfPresent, containsValue, forEach, merge, putIfAbsent, remove, replace, replace, replaceAllpublic LazyBindings()
public LazyBindings(Map<String,LazyBindings.Supplier> suppliers)
public void clear()
@NotNull public @NotNull Collection<Object> values()
public int size()
public boolean isEmpty()
public boolean containsKey(Object key)
containsKey in interface Map<String,Object>containsKey in interface BindingscontainsKey in class HashMap<String,Object>public boolean equals(Object o)
public int hashCode()
Copyright © 2010 - 2020 Adobe. All Rights Reserved