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>

@NotThreadSafe public class MemoizingMap<K,V> extends AbstractMap<K,V> implements 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.