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 void
clear()
V
compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
V
computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
V
computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<K,V>>
entrySet()
V
get(Object key)
V
getOrDefault(Object key, V defaultValue)
Default implementation from ConcurrentMap does not account for null values.boolean
isEmpty()
Set<K>
keySet()
V
merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
Default from ConcurrentMap not working because of null values.V
put(K key, V value)
void
putAll(Map<? extends K,? extends V> m)
V
putIfAbsent(K key, V value)
We cannot useCache.putIfAbsent(Object, Object)
since the map returns the value.V
remove(Object key)
boolean
remove(Object key, Object value)
V
replace(K key, V value)
boolean
replace(K key, V oldValue, V newValue)
int
size()
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:
putIfAbsent
in interfaceConcurrentMap<K,V>
- Specified by:
putIfAbsent
in interfaceMap<K,V>
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<K,V>
- Overrides:
containsKey
in classAbstractMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<K,V>
- Overrides:
containsValue
in 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:
computeIfAbsent
in interfaceConcurrentMap<K,V>
- Specified by:
computeIfAbsent
in interfaceMap<K,V>
-
computeIfPresent
public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
- Specified by:
computeIfPresent
in interfaceConcurrentMap<K,V>
- Specified by:
computeIfPresent
in interfaceMap<K,V>
-
getOrDefault
public V getOrDefault(Object key, V defaultValue)
Default implementation from ConcurrentMap does not account for null values.- Specified by:
getOrDefault
in interfaceConcurrentMap<K,V>
- Specified by:
getOrDefault
in interfaceMap<K,V>
-
-