@GwtCompatible public abstract class ForwardingConcurrentMap<K,V> extends ForwardingMap<K,V> implements ConcurrentMap<K,V>
default method warning: This class forwards calls to only some default methods. Specifically, it forwards calls only for methods that existed before
default methods were introduced. For newer methods, like forEach, it inherits
their default implementations. When those implementations invoke methods, they invoke methods on
the ForwardingConcurrentMap.
ForwardingMap.StandardEntrySet, ForwardingMap.StandardKeySet, ForwardingMap.StandardValues| Modifier | Constructor and Description |
|---|---|
protected |
ForwardingConcurrentMap()
Constructor for use by subclasses.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract ConcurrentMap<K,V> |
delegate()
Returns the backing delegate instance that methods are forwarded to.
|
V |
putIfAbsent(K key,
V value)
If the specified key is not already associated
with a value, associate it with the given value.
|
boolean |
remove(Object key,
Object value)
Removes the entry for a key only if currently mapped to a given value.
|
V |
replace(K key,
V value)
Replaces the entry for a key only if currently mapped to some value.
|
boolean |
replace(K key,
V oldValue,
V newValue)
Replaces the entry for a key only if currently mapped to a given value.
|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, standardClear, standardContainsKey, standardContainsValue, standardEquals, standardHashCode, standardIsEmpty, standardPutAll, standardRemove, standardToString, valuestoStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAllprotected ForwardingConcurrentMap()
protected abstract ConcurrentMap<K,V> delegate()
ForwardingObjectForwardingSet.delegate(). Concrete subclasses override this method to supply the
instance being decorated.delegate in class ForwardingMap<K,V>@CanIgnoreReturnValue public V putIfAbsent(K key, V value)
java.util.concurrent.ConcurrentMap
if (!map.containsKey(key))
return map.put(key, value);
else
return map.get(key);
except that the action is performed atomically.putIfAbsent in interface ConcurrentMap<K,V>putIfAbsent in interface Map<K,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keynull if there was no mapping for the key.
(A null return can also indicate that the map
previously associated null with the key,
if the implementation supports null values.)@CanIgnoreReturnValue public boolean remove(Object key, Object value)
java.util.concurrent.ConcurrentMap
if (map.containsKey(key) && Objects.equals(map.get(key), value)) {
map.remove(key);
return true;
} else
return false;
except that the action is performed atomically.@CanIgnoreReturnValue public V replace(K key, V value)
java.util.concurrent.ConcurrentMap
if (map.containsKey(key)) {
return map.put(key, value);
} else
return null;
except that the action is performed atomically.replace in interface ConcurrentMap<K,V>replace in interface Map<K,V>key - key with which the specified value is associatedvalue - value to be associated with the specified keynull if there was no mapping for the key.
(A null return can also indicate that the map
previously associated null with the key,
if the implementation supports null values.)@CanIgnoreReturnValue public boolean replace(K key, V oldValue, V newValue)
java.util.concurrent.ConcurrentMap
if (map.containsKey(key) && Objects.equals(map.get(key), oldValue)) {
map.put(key, newValue);
return true;
} else
return false;
except that the action is performed atomically.replace in interface ConcurrentMap<K,V>replace in interface Map<K,V>key - key with which the specified value is associatedoldValue - value expected to be associated with the specified keynewValue - value to be associated with the specified keytrue if the value was replacedCopyright © 2010–2018. All rights reserved.