Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.common.collect
Class ForwardingConcurrentMap<K,V>

    java.lang.Object
      com.google.common.collect.ForwardingObject
          com.google.common.collect.ForwardingMap<K,V>
              com.google.common.collect.ForwardingConcurrentMap<K,V>

All Implemented Interfaces:
  ConcurrentMap<K,V>, Map<K,V>

    public abstract class ForwardingConcurrentMap<K,V>

extends ForwardingMap<K,V>
implements ConcurrentMap<K,V>

A concurrent map which forwards all its method calls to another concurrent map. Subclasses should override one or more methods to modify the behavior of the backing map as desired per the decorator pattern.

Author:
  Charles Fry
See Also:
  `ForwardingObject`

Nested Class Summary

Nested classes/interfaces inherited from interface java.util.Map
`Map.Entry<K,V>`

Constructor Summary
`ForwardingConcurrentMap()`

Method Summary
`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.

Methods inherited from class com.google.common.collect.ForwardingMap
`clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values`

Methods inherited from class com.google.common.collect.ForwardingObject
`toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.Map
`clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values`

Constructor Detail

### ForwardingConcurrentMap

    public ForwardingConcurrentMap()

Method Detail

### delegate

    protected abstract ConcurrentMap<K,V> delegate()

  Description copied from class: `ForwardingObject`
  Returns the backing delegate instance that methods are forwarded to. Abstract subclasses generally override this method with an abstract method that has a more specific return type, such as `ForwardingSet.delegate()`. Concrete subclasses override this method to supply the instance being decorated.

  Specified by:
    `delegate` in class `ForwardingMap<K,V>`

### putIfAbsent

    public V putIfAbsent(K key,
                         V value)

  Description copied from interface: `java.util.concurrent.ConcurrentMap`
  If the specified key is not already associated with a value, associate it with the given value. This is equivalent to

         if (!map.containsKey(key))
             return map.put(key, value);
         else
             return map.get(key);

  except that the action is performed atomically.

  Specified by:
    `putIfAbsent` in interface `ConcurrentMap<K,V>`
  Parameters:
    `key` - key with which the specified value is to be associated
    `value` - value to be associated with the specified key
  Returns:
    the previous value associated with the specified key, or `null` 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.)

### remove

    public boolean remove(Object key,
                          Object value)

  Description copied from interface: `java.util.concurrent.ConcurrentMap`
  Removes the entry for a key only if currently mapped to a given value. This is equivalent to

         if (map.containsKey(key) && map.get(key).equals(value)) {
             map.remove(key);
             return true;
         } else return false;

  except that the action is performed atomically.

  Specified by:
    `remove` in interface `ConcurrentMap<K,V>`
  Parameters:
    `key` - key with which the specified value is associated
    `value` - value expected to be associated with the specified key
  Returns:
    `true` if the value was removed

### replace

    public V replace(K key,
                     V value)

  Description copied from interface: `java.util.concurrent.ConcurrentMap`
  Replaces the entry for a key only if currently mapped to some value. This is equivalent to

         if (map.containsKey(key)) {
             return map.put(key, value);
         } else return null;

  except that the action is performed atomically.

  Specified by:
    `replace` in interface `ConcurrentMap<K,V>`
  Parameters:
    `key` - key with which the specified value is associated
    `value` - value to be associated with the specified key
  Returns:
    the previous value associated with the specified key, or `null` 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.)

### replace

    public boolean replace(K key,
                           V oldValue,
                           V newValue)

  Description copied from interface: `java.util.concurrent.ConcurrentMap`
  Replaces the entry for a key only if currently mapped to a given value. This is equivalent to

         if (map.containsKey(key) && map.get(key).equals(oldValue)) {
             map.put(key, newValue);
             return true;
         } else return false;

  except that the action is performed atomically.

  Specified by:
    `replace` in interface `ConcurrentMap<K,V>`
  Parameters:
    `key` - key with which the specified value is associated
    `oldValue` - value expected to be associated with the specified key
    `newValue` - value to be associated with the specified key
  Returns:
    `true` if the value was replaced

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD