K - the key type.V - the value type.@NotThreadSafe public class MemoizingMap<K,V> extends AbstractMap<K,V> implements Map<K,V>
Map that is backed by a MemoizingMap.Master map that contains suppliers
for the values that are called lazily when required. This can reduce the amount of memory
required if there are a number of entries that may or may not be required in the most case.
For example, when rendering Velocity templates, the context map is populated with a lot of things that are only ever required occasionally.
Note: even though this class is effectively immutable and does not support direct mutation, the memoization strategy is not thread-safe and should not be used if thread-safety is required. Adding thread-safety to this class would be fairly trivial through.
| Modifier and Type | Class and Description |
|---|---|
static class |
MemoizingMap.Master<K,V>
Master that individual Maps can be printed from.
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(Object key) |
Set<Map.Entry<K,V>> |
entrySet() |
V |
get(Object key)
.
|
boolean |
isEmpty() |
Set<K> |
keySet() |
V |
remove(Object key) |
int |
size() |
clear, clone, containsValue, equals, hashCode, put, putAll, toString, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitclear, compute, computeIfAbsent, computeIfPresent, containsValue, equals, forEach, getOrDefault, hashCode, merge, put, putAll, putIfAbsent, remove, replace, replace, replaceAll, valuespublic boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in class AbstractMap<K,V>public int size()
public boolean isEmpty()
Copyright © 2002-2021 Atlassian. All Rights Reserved.