Package com.atlassian.jira.util.collect
Class MemoizingMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
com.atlassian.jira.util.collect.MemoizingMap<K,V>
- Type Parameters:
K- the key type.V- the value type.
- All Implemented Interfaces:
Map<K,V>
A
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMaster that individual Maps can be printed from.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> -
Method Summary
Methods inherited from class java.util.AbstractMap
clear, clone, containsValue, equals, hashCode, put, putAll, toString, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsValue, equals, forEach, getOrDefault, hashCode, merge, put, putAll, putIfAbsent, remove, replace, replace, replaceAll, values
-
Method Details
-
get
.Implements the local caching of a value from the master.
-
keySet
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V> - Overrides:
containsKeyin classAbstractMap<K,V>
-
entrySet
-
size
public int size() -
isEmpty
public boolean isEmpty() -
remove
-