Class ObjectEqualityComparator

  • All Implemented Interfaces:
    EqualityComparator<java.lang.Object>

    public final class ObjectEqualityComparator
    extends AbstractEqualityComparator<java.lang.Object>
    This default implementation of EqualityComparator uses object equality for comparisons by calling Object.hashCode() and Object.equals(java.lang.Object).
    Author:
    Sam Harwell
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object a, java.lang.Object b)
      This method tests if two objects are equal.
      int hashCode​(java.lang.Object obj)
      This method returns a hash code for the specified object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ObjectEqualityComparator

        public ObjectEqualityComparator()
    • Method Detail

      • hashCode

        public int hashCode​(java.lang.Object obj)
        This method returns a hash code for the specified object.

        This implementation returns obj.hashCode().

        Parameters:
        obj - The object.
        Returns:
        The hash code for obj.
      • equals

        public boolean equals​(java.lang.Object a,
                              java.lang.Object b)
        This method tests if two objects are equal.

        This implementation relies on object equality. If both objects are null, this method returns true. Otherwise if only a is null, this method returns false. Otherwise, this method returns the result of a.equals(b).

        Parameters:
        a - The first object to compare.
        b - The second object to compare.
        Returns:
        true if a equals b, otherwise false.