jodd.util.ref
Class ReferenceMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by jodd.util.ref.ReferenceMap<K,V>
All Implemented Interfaces:
java.util.concurrent.ConcurrentMap<K,V>, java.util.Map<K,V>

public class ReferenceMap<K,V>
extends java.util.AbstractMap<K,V>
implements java.util.concurrent.ConcurrentMap<K,V>

Concurrent hash map that wraps keys and/or values in SOFT or WEAK references. Does not support null keys or values. Uses identity equality for weak and soft keys.


Nested Class Summary
protected static interface ReferenceMap.Strategy
           
 
Field Summary
protected  java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object> delegate
           
protected  ReferenceType keyReferenceType
           
protected  ReferenceType valueReferenceType
           
 
Constructor Summary
ReferenceMap(ReferenceType keyReferenceType, ReferenceType valueReferenceType)
          Concurrent hash map that wraps keys and/or values based on specified reference types.
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set<java.util.Map.Entry<K,V>> entrySet()
           
 V get(java.lang.Object key)
           
 boolean isEmpty()
           
 V put(K key, V value)
           
 void putAll(java.util.Map<? extends K,? extends V> t)
           
 V putIfAbsent(K key, V value)
           
 V remove(java.lang.Object key)
           
 boolean remove(java.lang.Object key, java.lang.Object value)
           
 V replace(K key, V value)
           
 boolean replace(K key, V oldValue, V newValue)
           
 int size()
           
 
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, keySet, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode, keySet, values
 

Field Detail

delegate

protected java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object> delegate

keyReferenceType

protected final ReferenceType keyReferenceType

valueReferenceType

protected final ReferenceType valueReferenceType
Constructor Detail

ReferenceMap

public ReferenceMap(ReferenceType keyReferenceType,
                    ReferenceType valueReferenceType)
Concurrent hash map that wraps keys and/or values based on specified reference types.

Parameters:
keyReferenceType - key reference type
valueReferenceType - value reference type
Method Detail

get

public V get(java.lang.Object key)
Specified by:
get in interface java.util.Map<K,V>
Overrides:
get in class java.util.AbstractMap<K,V>

put

public V put(K key,
             V value)
Specified by:
put in interface java.util.Map<K,V>
Overrides:
put in class java.util.AbstractMap<K,V>

remove

public V remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map<K,V>
Overrides:
remove in class java.util.AbstractMap<K,V>

size

public int size()
Specified by:
size in interface java.util.Map<K,V>
Overrides:
size in class java.util.AbstractMap<K,V>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<K,V>
Overrides:
isEmpty in class java.util.AbstractMap<K,V>

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map<K,V>
Overrides:
containsKey in class java.util.AbstractMap<K,V>

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map<K,V>
Overrides:
containsValue in class java.util.AbstractMap<K,V>

putAll

public void putAll(java.util.Map<? extends K,? extends V> t)
Specified by:
putAll in interface java.util.Map<K,V>
Overrides:
putAll in class java.util.AbstractMap<K,V>

clear

public void clear()
Specified by:
clear in interface java.util.Map<K,V>
Overrides:
clear in class java.util.AbstractMap<K,V>

putIfAbsent

public V putIfAbsent(K key,
                     V value)
Specified by:
putIfAbsent in interface java.util.concurrent.ConcurrentMap<K,V>

remove

public boolean remove(java.lang.Object key,
                      java.lang.Object value)
Specified by:
remove in interface java.util.concurrent.ConcurrentMap<K,V>

replace

public boolean replace(K key,
                       V oldValue,
                       V newValue)
Specified by:
replace in interface java.util.concurrent.ConcurrentMap<K,V>

replace

public V replace(K key,
                 V value)
Specified by:
replace in interface java.util.concurrent.ConcurrentMap<K,V>

entrySet

public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface java.util.Map<K,V>
Specified by:
entrySet in class java.util.AbstractMap<K,V>


Copyright ©2008 Jodd Team