Package org.cache2k.core
Class ConcurrentMapWrapper<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- org.cache2k.core.ConcurrentMapWrapper<K,V>
-
- All Implemented Interfaces:
ConcurrentMap<K,V>,Map<K,V>
public class ConcurrentMapWrapper<K,V> extends AbstractMap<K,V> implements ConcurrentMap<K,V>
ConcurrentMap interface wrapper on top of a cache. The map interface does not cause calls to the cache source. An attached writer is called.- Author:
- Jens Wilke
-
-
Nested Class Summary
-
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>
-
-
Constructor Summary
Constructors Constructor Description ConcurrentMapWrapper(InternalCache<K,V> cache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Vcompute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)VcomputeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)VcomputeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()Vget(Object key)VgetOrDefault(Object key, V defaultValue)Default implementation from ConcurrentMap does not account for null values.booleanisEmpty()Set<K>keySet()Vmerge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)Default from ConcurrentMap not working because of null values.Vput(K key, V value)voidputAll(Map<? extends K,? extends V> m)VputIfAbsent(K key, V value)We cannot useCache.putIfAbsent(Object, Object)since the map returns the value.Vremove(Object key)booleanremove(Object key, Object value)Vreplace(K key, V value)booleanreplace(K key, V oldValue, V newValue)intsize()Collection<V>values()-
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.concurrent.ConcurrentMap
forEach, replaceAll
-
-
-
-
Constructor Detail
-
ConcurrentMapWrapper
public ConcurrentMapWrapper(InternalCache<K,V> cache)
-
-
Method Detail
-
putIfAbsent
public V putIfAbsent(K key, V value)
We cannot useCache.putIfAbsent(Object, Object)since the map returns the value.- Specified by:
putIfAbsentin interfaceConcurrentMap<K,V>- Specified by:
putIfAbsentin interfaceMap<K,V>
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>- Overrides:
containsKeyin classAbstractMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,V>- Overrides:
containsValuein classAbstractMap<K,V>
-
clear
public void clear()
-
values
public Collection<V> values()
-
computeIfAbsent
public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
- Specified by:
computeIfAbsentin interfaceConcurrentMap<K,V>- Specified by:
computeIfAbsentin interfaceMap<K,V>
-
computeIfPresent
public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
- Specified by:
computeIfPresentin interfaceConcurrentMap<K,V>- Specified by:
computeIfPresentin interfaceMap<K,V>
-
getOrDefault
public V getOrDefault(Object key, V defaultValue)
Default implementation from ConcurrentMap does not account for null values.- Specified by:
getOrDefaultin interfaceConcurrentMap<K,V>- Specified by:
getOrDefaultin interfaceMap<K,V>
-
-