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 into
SoftReference
- 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>>
entrySet
This is a lazily created set of entries that is essentially a view to actual dataprotected HashMap<K,SoftReference<V>>
map
This 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
Modifier and Type Method Description protected void
checkReferenceQueue()
Cleanup all references collected by GC so farvoid
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<K,V>>
entrySet()
V
get(Object key)
boolean
isEmpty()
Set<K>
keySet()
V
put(K key, V value)
void
putAll(Map<? extends K,? extends V> m)
V
remove(Object key)
int
size()
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 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
-
-
Constructor Details
-
SoftValueMap
public SoftValueMap() -
SoftValueMap
public SoftValueMap(int initialCapacity) -
SoftValueMap
-
-
Method Details
-
size
public int size()- Specified by:
size
in interfaceMap<K,V>
- Overrides:
size
in classAbstractMap<K,V>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceMap<K,V>
- Overrides:
isEmpty
in classAbstractMap<K,V>
-
containsKey
- Specified by:
containsKey
in interfaceMap<K,V>
- Overrides:
containsKey
in classAbstractMap<K,V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,V>
- Overrides:
containsValue
in classAbstractMap<K,V>
-
get
- Specified by:
get
in interfaceMap<K,V>
- Overrides:
get
in classAbstractMap<K,V>
-
put
- Specified by:
put
in interfaceMap<K,V>
- Overrides:
put
in classAbstractMap<K,V>
-
remove
- Specified by:
remove
in interfaceMap<K,V>
- Overrides:
remove
in classAbstractMap<K,V>
-
putAll
- Specified by:
putAll
in interfaceMap<K,V>
- Overrides:
putAll
in classAbstractMap<K,V>
-
clear
public void clear()- Specified by:
clear
in interfaceMap<K,V>
- Overrides:
clear
in classAbstractMap<K,V>
-
keySet
- Specified by:
keySet
in interfaceMap<K,V>
- Overrides:
keySet
in classAbstractMap<K,V>
-
values
- Specified by:
values
in interfaceMap<K,V>
- Overrides:
values
in classAbstractMap<K,V>
-
entrySet
- Specified by:
entrySet
in interfaceMap<K,V>
- Specified by:
entrySet
in classAbstractMap<K,V>
-
checkReferenceQueue
protected void checkReferenceQueue()Cleanup all references collected by GC so far
-