public abstract class IdentityIndexer<K,V> extends Indexer<K,V>
Indexer
that distinguishes and identifies elements using identity comparison of object keys.
It uses System.identityHashCode(Object)
method instead of
Object.hashCode()
method to compute hashcode and reference comparison
instead of Object.equals(Object)
method to determine identity.
The IdentityIndexer itself is not serializable. However, concrete subclasses shall be serializable in order to support serialization of indexed set and map.
Modifier | Constructor and Description |
---|---|
protected |
IdentityIndexer()
Sole constructor; for invocation by subclass constructors, typically implicit.
|
Modifier and Type | Method and Description |
---|---|
int |
hashCodeByKey(K key)
Returns hash code for specified object key; called when performing operations using object keys.
|
int |
hashCodeByValue(V value)
Returns hash code for specified value; called when performing value-based operations, including rehash.
|
boolean |
matchesByKey(K key,
V value)
Determines if specified object key matches specified value; called when performing operations using object keys.
|
boolean |
matchesByValue(V new_value,
V old_value)
Determines if specified new value matches specified old value; called when performing value-based operations.
|
getNumberKey, getObjectKey, hashCodeByKey, matchesByKey
protected IdentityIndexer()
This implementation does nothing.
public int hashCodeByValue(V value)
This implementation delegates to System.
expression.identityHashCode
(getObjectKey
(value))
hashCodeByValue
in class Indexer<K,V>
public boolean matchesByValue(V new_value, V old_value)
This implementation delegates to (
expression.getObjectKey
(new_value) == getObjectKey
(old_value))
matchesByValue
in class Indexer<K,V>
public int hashCodeByKey(K key)
This implementation delegates to System.
expression.identityHashCode
(key)
hashCodeByKey
in class Indexer<K,V>
UnsupportedOperationException
- if this strategy does not support object keys.public boolean matchesByKey(K key, V value)
This implementation delegates to (key ==
expression.getObjectKey
(value))
matchesByKey
in class Indexer<K,V>
UnsupportedOperationException
- if this strategy does not support object keys.Copyright © 2015 Devexperts. All Rights Reserved.