-
public interface HashingStrategy<T>
Abstraction for hash code generation and equality comparison.
-
-
Field Summary
Fields Modifier and Type Field Description static HashingStrategy
JAVA_HASHER
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
equals(T a, T b)
Returnstrue
if the arguments are equal to each other andfalse
otherwise.int
hashCode(T obj)
Generate a hash code forobj
.
-
-
-
Field Detail
-
JAVA_HASHER
static final HashingStrategy JAVA_HASHER
-
-
Method Detail
-
hashCode
int hashCode(T obj)
Generate a hash code forobj
.This method must obey the same relationship that
Object.hashCode()
has withObject.equals(Object)
:- Calling this method multiple times with the same
obj
should return the same result - If
equals(Object, Object)
with parametersa
andb
returnstrue
then the return value for this method for parametersa
andb
must return the same result - If
equals(Object, Object)
with parametersa
andb
returnsfalse
then the return value for this method for parametersa
andb
does not have to return different results results. However this property is desirable. - if
obj
isnull
then this method return0
- Calling this method multiple times with the same
-
equals
boolean equals(T a, T b)
Returnstrue
if the arguments are equal to each other andfalse
otherwise. This method has the following restrictions:- reflexive -
equals(a, a)
should return true - symmetric -
equals(a, b)
returnstrue
ifequals(b, a)
returnstrue
- transitive - if
equals(a, b)
returnstrue
andequals(a, c)
returnstrue
thenequals(b, c)
should also returntrue
- consistent -
equals(a, b)
should return the same result when called multiple times assuminga
andb
remain unchanged relative to the comparison criteria - if
a
andb
are bothnull
then this method returnstrue
- if
a
isnull
andb
is non-null
, ora
is non-null
andb
isnull
then this method returnsfalse
- reflexive -
-
-