Package org.apache.cayenne.util
Class SoftValueMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- org.apache.cayenne.util.SoftValueMap<K,V>
-
- All Implemented Interfaces:
Serializable,Map<K,V>
public class SoftValueMap<K,V> extends AbstractMap<K,V> implements Serializable
Map that stores values wrapped intoSoftReference- Since:
- 4.1
- See Also:
WeakValueMap, Serialized Form
-
-
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>
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<Map.Entry<K,V>>entrySetThis is a lazily created set of entries that is essentially a view to actual dataprotected HashMap<K,R>mapThis is a main data storage used for most operationsprotected ReferenceQueue<V>referenceQueue
-
Constructor Summary
Constructors Constructor Description SoftValueMap()SoftValueMap(int initialCapacity)SoftValueMap(Map<? extends K,? extends V> m)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckReferenceQueue()Cleanup all references collected by GC so farvoidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()Vget(Object key)booleanisEmpty()Set<K>keySet()Vput(K key, V value)voidputAll(Map<? extends K,? extends V> m)Vremove(Object key)intsize()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.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Field Detail
-
map
protected transient HashMap<K,R extends Reference<V>> map
This is a main data storage used for most operations
-
referenceQueue
protected transient ReferenceQueue<V> referenceQueue
-
-
Method Detail
-
size
public int size()
- Specified by:
sizein interfaceMap<K,V>- Overrides:
sizein classAbstractMap<K,V>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceMap<K,V>- Overrides:
isEmptyin classAbstractMap<K,V>
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>- Overrides:
containsKeyin classAbstractMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,V>- Overrides:
containsValuein classAbstractMap<K,V>
-
get
public V get(Object key)
- Specified by:
getin interfaceMap<K,V>- Overrides:
getin classAbstractMap<K,V>
-
put
public V put(K key, V value)- Specified by:
putin interfaceMap<K,V>- Overrides:
putin classAbstractMap<K,V>
-
remove
public V remove(Object key)
- Specified by:
removein interfaceMap<K,V>- Overrides:
removein classAbstractMap<K,V>
-
putAll
public void putAll(Map<? extends K,? extends V> m)
- Specified by:
putAllin interfaceMap<K,V>- Overrides:
putAllin classAbstractMap<K,V>
-
clear
public void clear()
- Specified by:
clearin interfaceMap<K,V>- Overrides:
clearin classAbstractMap<K,V>
-
keySet
public Set<K> keySet()
- Specified by:
keySetin interfaceMap<K,V>- Overrides:
keySetin classAbstractMap<K,V>
-
values
public Collection<V> values()
- Specified by:
valuesin interfaceMap<K,V>- Overrides:
valuesin classAbstractMap<K,V>
-
entrySet
public Set<Map.Entry<K,V>> entrySet()
- Specified by:
entrySetin interfaceMap<K,V>- Specified by:
entrySetin classAbstractMap<K,V>
-
checkReferenceQueue
protected void checkReferenceQueue()
Cleanup all references collected by GC so far
-
-