|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.rode.thesis.meta.reflect.WeakReferenceEntry<T>
T
- The type of object stored as a weak reference by this entry.public class WeakReferenceEntry<T>
A weak reference entry represents an object stored
as a weak reference, but where the hashCode()
and
equals(Object)
methods of the object are used over
the identity comparison performed by java.lang.ref.WeakReference
.
Since stored as a weak reference, the wrapped object may be garbage collected at any time.
Implementation notes:
Delegation is favoured over inheritance of
java.lang.ref.WeakReference
.
Field Summary | |
---|---|
private int |
hashCode
The hash code of the object stored as a weak reference from the time of creation of this entry. |
private WeakReference<T> |
reference
The weak reference storing the object. |
Constructor Summary | |
---|---|
WeakReferenceEntry(T object)
Constructor. |
Method Summary | |
---|---|
boolean |
equals(Object object)
Returns true if object represents the same object as this
entry, false if not. |
T |
get()
Returns the object stored as a weak reference, or null if garbage collected. |
int |
hashCode()
Returns the hash code of this entry. |
String |
toString()
Returns the string representation of this entry. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final int hashCode
private final WeakReference<T> reference
Never null, but the actual object may be if it was garbage collected.
Constructor Detail |
---|
public WeakReferenceEntry(T object)
object
- The object to store as weak reference; cannot be null.
NullPointerException
- If object
is null.Method Detail |
---|
public boolean equals(Object object)
object
represents the same object as this
entry, false if not. The test for object equality is performed using equals.
equals
in class Object
object
- The object to test; can be null.
public T get()
public int hashCode()
The hash code corresponds to the hash code of the object stored as a weak reference at the time of creation of this entry.
hashCode
in class Object
public String toString()
toString
in class Object
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |