Package org.eclipse.net4j.util.ref

# Class ReferenceValueMap<K,V>

java.lang.Object
java.util.AbstractMap<K,V>
org.eclipse.net4j.util.ref.ReferenceValueMap2<K,V>
org.eclipse.net4j.util.ref.ReferenceValueMap<K,V>

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

Direct Known Subclasses:
  `ReferenceValueMap.Soft`, `ReferenceValueMap.Strong`, `ReferenceValueMap.Weak`

public abstract class ReferenceValueMap<K,V> extends ReferenceValueMap2<K,V> implements ConcurrentMap<K,V>
A `ConcurrentMap` implementation that uses `KeyedReference` instances (`KeyedStrongReference`, `KeyedSoftReference`, `KeyedWeakReference` or `KeyedPhantomReference`) as its values.

A `ReferenceValueMap` can be used to cache mappings until the value of the mapping is no longer reachable from outside of the map

Note: This map is not synchronized. If it is to be used by multiple threads concurrently the user is responsible for applying proper external synchronization!

Author:
  Eike Stepper

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`ReferenceValueMap.Soft<K,V>`
`static class`
`ReferenceValueMap.Strong<K,V>`
`static class`
`ReferenceValueMap.Weak<K,V>`

## 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>`

## Nested classes/interfaces inherited from interface java.util.Map

`Map.Entry<K extends Object,V extends Object>`

## Constructor Summary

Constructors
Constructor
Description
`ReferenceValueMap()`
`ReferenceValueMap(ConcurrentMap<K,KeyedReference<K,V>> map)`

## Method Summary

Modifier and Type
Method
Description
`V`
`putIfAbsent(K key, V value)`
`boolean`
`remove(Object key, Object value)`
`V`
`replace(K key, V value)`
`boolean`
`replace(K key, V oldValue, V newValue)`

### Methods inherited from class org.eclipse.net4j.util.ref.ReferenceValueMap2

`clear, containsKey, containsValue, createQueue, createReference, dereference, entrySet, get, internalPurgeQueue, isEmpty, purged, purgeQueue, put, remove, removeAll, size`

### Methods inherited from class java.util.AbstractMap

`clone, equals, hashCode, keySet, putAll, toString, values`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.util.concurrent.ConcurrentMap

`compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll`

### Methods inherited from interface java.util.Map

`clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values`

## Constructor Details

### ReferenceValueMap

public ReferenceValueMap()

### ReferenceValueMap

public ReferenceValueMap(ConcurrentMap<K,KeyedReference<K,V>> map)

## Method Details

### putIfAbsent

public V putIfAbsent(K key, V value)

Specified by:
  `putIfAbsent` in interface `ConcurrentMap<K,V>`
Specified by:
  `putIfAbsent` in interface `Map<K,V>`

### replace

public V replace(K key, V value)

Specified by:
  `replace` in interface `ConcurrentMap<K,V>`
Specified by:
  `replace` in interface `Map<K,V>`

### replace

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

Specified by:
  `replace` in interface `ConcurrentMap<K,V>`
Specified by:
  `replace` in interface `Map<K,V>`

### remove

public boolean remove(Object key, Object value)

Specified by:
  `remove` in interface `ConcurrentMap<K,V>`
Specified by:
  `remove` in interface `Map<K,V>`