public abstract class ConcurrentFactoryMap<K,V>
extends java.lang.Object
implements java.util.concurrent.ConcurrentMap<K,V>
create(Object)
method) on first get(Object)
access.
This map is THREAD SAFE.
It's guaranteed that two get(Object)
method calls with the same key will return the same value (i.e. the created value stored atomically).
For the not thread-safe (but possibly faster and more memory-efficient) alternative please use FactoryMap
instead.Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
static <K,V> java.util.concurrent.ConcurrentMap<K,V> |
create(Function<? super K,? extends V> computeValue,
java.util.function.Supplier<? extends java.util.concurrent.ConcurrentMap<K,V>> mapCreator) |
protected abstract V |
create(K key) |
protected java.util.concurrent.ConcurrentMap<K,V> |
createMap() |
static <T,V> java.util.concurrent.ConcurrentMap<T,V> |
createMap(Function<? super T,? extends V> computeValue) |
static <T,V> java.util.concurrent.ConcurrentMap<T,V> |
createWeakMap(Function<? super T,? extends V> compute) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
V |
get(java.lang.Object key) |
boolean |
isEmpty() |
java.util.Set<K> |
keySet() |
V |
put(K key,
V value) |
void |
putAll(java.util.Map<? extends K,? extends V> m) |
V |
putIfAbsent(K key,
V value) |
V |
remove(java.lang.Object key) |
boolean |
remove(java.lang.Object key,
java.lang.Object value) |
boolean |
removeValue(java.lang.Object value) |
V |
replace(K key,
V value) |
boolean |
replace(K key,
V oldValue,
V newValue) |
int |
size() |
java.lang.String |
toString() |
java.util.Collection<V> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public final boolean containsKey(java.lang.Object key)
public boolean removeValue(java.lang.Object value)
public boolean containsValue(java.lang.Object value)
public boolean remove(java.lang.Object key, java.lang.Object value)
public java.lang.String toString()
toString
in class java.lang.Object
public static <T,V> java.util.concurrent.ConcurrentMap<T,V> createMap(Function<? super T,? extends V> computeValue)
public static <K,V> java.util.concurrent.ConcurrentMap<K,V> create(Function<? super K,? extends V> computeValue, java.util.function.Supplier<? extends java.util.concurrent.ConcurrentMap<K,V>> mapCreator)
public static <T,V> java.util.concurrent.ConcurrentMap<T,V> createWeakMap(Function<? super T,? extends V> compute)