protected static class AbstractReferenceMap.ReferenceEntry<K,V> extends AbstractHashedMap.HashEntry<K,V>
If getKey() or getValue() returns null, it means the mapping is stale and should be removed.
hashCode, key, next, value
Constructor and Description |
---|
ReferenceEntry(AbstractReferenceMap<K,V> parent,
AbstractHashedMap.HashEntry<K,V> next,
int hashCode,
K key,
V value)
Creates a new entry object for the ReferenceMap.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Compares this map entry to another.
|
K |
getKey()
Gets the key from the entry.
|
V |
getValue()
Gets the value from the entry.
|
int |
hashCode()
Gets the hashcode of the entry using temporary hard references.
|
protected AbstractReferenceMap.ReferenceEntry<K,V> |
next()
Gets the next entry in the bucket.
|
protected void |
nullValue()
This method can be overriden to provide custom logic to purge value
|
protected void |
onPurge()
This is the callback for custom "after purge" logic
|
protected boolean |
purge(Reference<?> ref)
Purges the specified reference
|
V |
setValue(V obj)
Sets the value of the entry.
|
protected <T> Object |
toReference(AbstractReferenceMap.ReferenceStrength type,
T referent,
int hash)
Constructs a reference of the given type to the given referent.
|
toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
comparingByKey, comparingByKey, comparingByValue, comparingByValue
public ReferenceEntry(AbstractReferenceMap<K,V> parent, AbstractHashedMap.HashEntry<K,V> next, int hashCode, K key, V value)
parent
- the parent mapnext
- the next entry in the hash buckethashCode
- the hash code of the keykey
- the keyvalue
- the valuepublic K getKey()
public V getValue()
public boolean equals(Object obj)
This implementation uses isEqualKey
and
isEqualValue
on the main map for comparison.
public int hashCode()
This implementation uses hashEntry
on the main map.
protected <T> Object toReference(AbstractReferenceMap.ReferenceStrength type, T referent, int hash)
T
- the type of the referenced objecttype
- HARD, SOFT or WEAKreferent
- the object to refer tohash
- the hash code of the key of the mapping;
this number might be different from referent.hashCode() if
the referent represents a value and not a keyprotected void onPurge()
protected boolean purge(Reference<?> ref)
ref
- the reference to purgeprotected AbstractReferenceMap.ReferenceEntry<K,V> next()
protected void nullValue()
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.