Interface Hash<K,​T>

  • Type Parameters:
    K - type for hashCode and first equals parameter
    T - type for second equals parameter
    All Known Implementing Classes:
    DuplicateNode.NodeHash, Storage.PrimitiveIdHash

    public interface Hash<K,​T>
    An interface allowing injection of hashcode and equality implementation based on some inner state of an object for a set. It supports two type parameters to implement effective foreign key implementation inside Storage, but for basic use, both type parameters are the same. For use cases, see Storage.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean equals​(K k, T t)
      Compare two instances for semantic or lookup equality.
      int getHashCode​(K k)
      Get hashcode for given instance, based on some inner state of the instance.
    • Method Detail

      • getHashCode

        int getHashCode​(K k)
        Get hashcode for given instance, based on some inner state of the instance. The returned hashcode should remain constant over the time, so it should be based on some instance invariant.
        Parameters:
        k - the object to compute hashcode for
        Returns:
        computed hashcode
      • equals

        boolean equals​(K k,
                       T t)
        Compare two instances for semantic or lookup equality. For use cases where it compares different types, refer to Storage.
        Parameters:
        k - the object to compare
        t - the object to compare
        Returns:
        true if the objects are semantically equivalent, or if k uniquely identifies t in given class.