Package org.apache.xbean.propertyeditor
Class ReferenceIdentityMap
java.lang.Object
org.apache.xbean.propertyeditor.ReferenceIdentityMap
- All Implemented Interfaces:
Map
Streamlined version of a WeakIdentityHashMap. Provides Identity semantics with
Weak References to keys. This allows proxies to be GC'ed when no longer referenced
by clients.
BasicProxymanager.destroyProxy()
need not be invoked when a
proxy is no longer needed. Note that this is not a full Map implementation.
The iteration and collection capabilities of Map have been discarded to keep the
implementation lightweight.
Much of this code was cribbed from the Commons Collection 3.1 implementation of
ReferenceIdentityMap
and AbstractReferenceMap
.
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the map, resetting the size to zero and nullifying references to avoid garbage collection issues.boolean
containsKey
(Object key) Checks whether the map contains the specified key.boolean
containsValue
(Object value) Checks whether the map contains the specified value.entrySet()
Gets the value mapped to the key specified.boolean
isEmpty()
Checks whether the map is currently empty.keySet()
Puts a key-value entry into this map.void
Removes the specified mapping from this map.int
size()
Gets the size of the map.values()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
ReferenceIdentityMap
public ReferenceIdentityMap()
-
-
Method Details
-
size
public int size()Gets the size of the map. -
isEmpty
public boolean isEmpty()Checks whether the map is currently empty. -
containsKey
Checks whether the map contains the specified key.- Specified by:
containsKey
in interfaceMap
- Parameters:
key
- the key to search for- Returns:
- true if the map contains the key
-
containsValue
Checks whether the map contains the specified value.- Specified by:
containsValue
in interfaceMap
- Parameters:
value
- the value to search for- Returns:
- true if the map contains the value
-
get
Gets the value mapped to the key specified. -
put
Puts a key-value entry into this map. Neither the key nor the value may be null. -
remove
Removes the specified mapping from this map. -
clear
public void clear()Clears the map, resetting the size to zero and nullifying references to avoid garbage collection issues. -
values
-
putAll
-
entrySet
-
keySet
-