Package co.aikar.util

Class LoadingMap<K,​V>

java.lang.Object
java.util.AbstractMap<K,​V>
co.aikar.util.LoadingMap<K,​V>
Type Parameters:
K - Key
V - Value
All Implemented Interfaces:
Map<K,​V>

public class LoadingMap<K,​V> extends AbstractMap<K,​V>
Allows you to pass a Loader function that when a key is accessed that doesn't exists, automatically loads the entry into the map by calling the loader Function. .get() Will only return null if the Loader can return null. You may pass any backing Map to use. This class is not thread safe and should be wrapped with Collections.synchronizedMap on the OUTSIDE of the LoadingMap if needed. Do not wrap the backing map with Collections.synchronizedMap.