Interface HashingStrategy<T>


  • public interface HashingStrategy<T>
    Abstraction for hash code generation and equality comparison.
    • Method Detail

      • hashCode

        int hashCode​(T obj)
        Generate a hash code for obj.

        This method must obey the same relationship that Object.hashCode() has with Object.equals(Object):

        • Calling this method multiple times with the same obj should return the same result
        • If equals(Object, Object) with parameters a and b returns true then the return value for this method for parameters a and b must return the same result
        • If equals(Object, Object) with parameters a and b returns false then the return value for this method for parameters a and b does not have to return different results results. However this property is desirable.
        • if obj is null then this method return 0
      • equals

        boolean equals​(T a,
                       T b)
        Returns true if the arguments are equal to each other and false otherwise. This method has the following restrictions:
        • reflexive - equals(a, a) should return true
        • symmetric - equals(a, b) returns true if equals(b, a) returns true
        • transitive - if equals(a, b) returns true and equals(a, c) returns true then equals(b, c) should also return true
        • consistent - equals(a, b) should return the same result when called multiple times assuming a and b remain unchanged relative to the comparison criteria
        • if a and b are both null then this method returns true
        • if a is null and b is non-null, or a is non-null and b is null then this method returns false