class SoftIdentityReference<T> extends SoftReference<T> implements Referrer<T>, Serializable
Ref.SOFT_IDENTITY
Modifier and Type | Field and Description |
---|---|
private int |
hash |
private static long |
serialVersionUID |
Constructor and Description |
---|
SoftIdentityReference(T k,
ReferenceQueue<? super T> q) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
Equals is calculated on IDENTITY or EQUALITY.
|
int |
hashCode()
Standard hashCode calculation for IDENTITY based references, where k
is the referent.
|
private void |
readObject(ObjectInputStream stream) |
String |
toString() |
private Object |
writeReplace() |
get
clear, enqueue, isEnqueued
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
clear, enqueue, get, isEnqueued
private static final long serialVersionUID
private final int hash
SoftIdentityReference(T k, ReferenceQueue<? super T> q)
public boolean equals(Object o)
Referrer
Equals is calculated on IDENTITY or EQUALITY.
IDENTITY calculation:
if (this == o) return true;
if (!(o instanceof Referrer)) return false;
Object k1 = get();
Object k2 = ((Referrer) o).get();
if ( k1 != null && k1 == k2 ) return true;
return ( k1 == null && k2 == null && hashCode() == o.hashCode());
if (this == o) return true; // Same reference.
if (!(o instanceof Referrer)) return false;
Object k1 = get();
Object k2 = ((Referrer) o).get();
if ( k1 != null && k1.equals(k2)) return true;
return ( k1 == null && k2 == null && hashCode() == o.hashCode());
public int hashCode()
Referrer
Standard hashCode calculation for IDENTITY based references, where k is the referent. This may be stored in a final field:
int hash = 7;
hash = 29 * hash + System.identityHashCode(k);
hash = 29 * hash + k.getClass().hashCode();
Standard hashCode calculation for EQUALITY based references, where k is the referent:
int hash = 7;
hash = 29 * hash + k.hashCode();
hash = 29 * hash + k.getClass().hashCode();
The hash must be calculated during construction and if the reference is cleared, the recorded hashCode returned. While the referent remains reachable the hashCode must be calculated each time.
private Object writeReplace()
private void readObject(ObjectInputStream stream) throws InvalidObjectException
InvalidObjectException
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.