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>
Map that stores values wrapped into
SoftReference- Since:
- 4.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
FieldsModifier and TypeFieldDescriptionThis is a lazily created set of entries that is essentially a view to actual dataprotected HashMap<K, SoftReference<V>> This is a main data storage used for most operationsprotected ReferenceQueue<V> -
Constructor Summary
ConstructorsConstructorDescriptionSoftValueMap(int initialCapacity) SoftValueMap(Map<? extends K, ? extends V> m) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCleanup all references collected by GC so farvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanisEmpty()keySet()voidvoidsetKeyCleanupCallback(Consumer<K> keyCleanupCallback) Set callback that will be notified with a key on each value removal due to the corresponding value reference cleaned up by the GC.intsize()values()Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
map
This is a main data storage used for most operations -
referenceQueue
-
entrySet
This is a lazily created set of entries that is essentially a view to actual data -
keyCleanupCallback
- Since:
- 4.2.2
-
-
Constructor Details
-
SoftValueMap
public SoftValueMap() -
SoftValueMap
public SoftValueMap(int initialCapacity) -
SoftValueMap
-
-
Method Details
-
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
- Specified by:
containsKeyin interfaceMap<K,V> - Overrides:
containsKeyin classAbstractMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V> - Overrides:
containsValuein classAbstractMap<K,V>
-
get
- Specified by:
getin interfaceMap<K,V> - Overrides:
getin classAbstractMap<K,V>
-
put
- Specified by:
putin interfaceMap<K,V> - Overrides:
putin classAbstractMap<K,V>
-
remove
- Specified by:
removein interfaceMap<K,V> - Overrides:
removein classAbstractMap<K,V>
-
putAll
- 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
- Specified by:
keySetin interfaceMap<K,V> - Overrides:
keySetin classAbstractMap<K,V>
-
values
- Specified by:
valuesin interfaceMap<K,V> - Overrides:
valuesin classAbstractMap<K,V>
-
entrySet
- Specified by:
entrySetin interfaceMap<K,V> - Specified by:
entrySetin classAbstractMap<K,V>
-
setKeyCleanupCallback
Set callback that will be notified with a key on each value removal due to the corresponding value reference cleaned up by the GC.- Parameters:
keyCleanupCallback- callback to set- Since:
- 4.2.2
-
checkReferenceQueue
protected void checkReferenceQueue()Cleanup all references collected by GC so far
-