Class NaturalHasher<V>

  • Type Parameters:
    V - the value type
    All Implemented Interfaces:
    Hasher<V>

    public class NaturalHasher<V>
    extends Object
    implements Hasher<V>
    NaturalHasher provides a Hasher implementation based upon an object's internal hashCode and equals implementation.
    Author:
    mf 2011.01.07
    • Field Detail

      • INSTANCE

        public static final NaturalHasher INSTANCE
        A singleton instance of the NaturalHasher.
    • Constructor Detail

      • NaturalHasher

        public NaturalHasher()
    • Method Detail

      • hashCode

        public int hashCode​(V o)
        Return a hash for the specified object.
        Specified by:
        hashCode in interface Hasher<V>
        Parameters:
        o - the object to hash
        Returns:
        the hash
      • equals

        public boolean equals​(V va,
                              V vb)
        Compare two objects for equality.
        Specified by:
        equals in interface Hasher<V>
        Parameters:
        va - the first object to compare
        vb - the second object to compare
        Returns:
        true iff the object are equal