Package com.sun.jini.collection
Class WeakKeyReference
java.lang.Object
java.lang.ref.Reference<T>
java.lang.ref.WeakReference
com.sun.jini.collection.WeakKeyReference
A weak reference to a key in a table. Its hash code is that of its key at the time of the
reference's creation. Its
equals method will compare itself to another
WeakKeyReference, or to another object that is then compared to the key held by this
reference. This class is public so that it can be used in other tables for which
WeakTable won't work.
- Author:
- Sun Microsystems, Inc.
-
Constructor Summary
ConstructorsConstructorDescriptionWeakKeyReference(Object key) Create a newWeakReferenceto the given key.WeakKeyReference(Object key, ReferenceQueue refQueue) Create a newWeakReferenceto the given key, placing the cleared reference on the specifiedReferenceQueue. -
Method Summary
Methods inherited from class java.lang.ref.Reference
clear, clone, enqueue, get, isEnqueued, reachabilityFence, refersTo
-
Constructor Details
-
WeakKeyReference
Create a newWeakReferenceto the given key. The reference is placed on no queue. -
WeakKeyReference
Create a newWeakReferenceto the given key, placing the cleared reference on the specifiedReferenceQueue.
-
-
Method Details
-
hashCode
public int hashCode()Return the key's hashCode remembered from the time of reference creation. If you intend to insert the key in a table after changing the key in a way that affects the hashCode, you will need to create a newWeakKeyReferencefor that new table. -
equals
Equivalence for WeakKeyReference is defined as follows:- If the other reference is to
this object, return
true. - If this object's key is cleared, return
false. - If the other reference is to a WeakKeyReference object, return
falseif the other's key is cleared; otherwise return the result of invokingequalson the two keys.
- If the other reference is to
this object, return
-