Package io.netty.util
Interface HashingStrategy<T>
-
public interface HashingStrategy<T>Abstraction for hash code generation and equality comparison.
-
-
Field Summary
Fields Modifier and Type Field Description static HashingStrategyJAVA_HASHER
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanequals(T a, T b)Returnstrueif the arguments are equal to each other andfalseotherwise.inthashCode(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
objshould return the same result - If
equals(Object, Object)with parametersaandbreturnstruethen the return value for this method for parametersaandbmust return the same result - If
equals(Object, Object)with parametersaandbreturnsfalsethen the return value for this method for parametersaandbdoes not have to return different results results. However this property is desirable. - if
objisnullthen this method return0
- Calling this method multiple times with the same
-
equals
boolean equals(T a, T b)
Returnstrueif the arguments are equal to each other andfalseotherwise. This method has the following restrictions:- reflexive -
equals(a, a)should return true - symmetric -
equals(a, b)returnstrueifequals(b, a)returnstrue - transitive - if
equals(a, b)returnstrueandequals(a, c)returnstruethenequals(b, c)should also returntrue - consistent -
equals(a, b)should return the same result when called multiple times assumingaandbremain unchanged relative to the comparison criteria - if
aandbare bothnullthen this method returnstrue - if
aisnullandbis non-null, orais non-nullandbisnullthen this method returnsfalse
- reflexive -
-
-