Class EqualsHashCodeBuilder

java.lang.Object
org.identityconnectors.common.EqualsHashCodeBuilder

public final class EqualsHashCodeBuilder extends Object
Builder to simplify implementing the Object.equals(Object) and Object.hashCode() methods. This class uses ArrayList's implementation of ArrayList.equals(Object) and ArrayList.hashCode() and takes special care with deep arrays and Collection based objects.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct the builder.
  • Method Summary

    Modifier and Type
    Method
    Description
    append(Object object)
    Appends the field value to an ArrayList to help facilitate equality testing.
    void
    This method will attempt to use reflection to get all the properties that make up the identity of the object.
    boolean
    Determine equality based on the value of the members append to the builder.
    int
    Determine the hashcode based on the various members.
    Show the contents that make up the key.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • EqualsHashCodeBuilder

      public EqualsHashCodeBuilder()
      Construct the builder.
  • Method Details

    • append

      public EqualsHashCodeBuilder append(Object object)
      Appends the field value to an ArrayList to help facilitate equality testing.
      Parameters:
      object - the object to append
      Returns:
      this instance
      Throws:
      IllegalArgumentException - if a collection is passed since collections do not support value based equality. Sets, Lists, and Maps will work since they support value based equality.
    • appendBean

      public void appendBean(Object obj)
      This method will attempt to use reflection to get all the properties that make up the identity of the object. It will append(Object) all results from get methods that have a corresponding set method.
    • equals

      public boolean equals(Object obj)
      Determine equality based on the value of the members append to the builder.
      Overrides:
      equals in class Object
      Parameters:
      obj - the reference object with which to compare.
      Returns:
      true if this object is the same as the obj argument; false otherwise.
      See Also:
    • hashCode

      public int hashCode()
      Determine the hashcode based on the various members.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this object.
      See Also:
    • toString

      public String toString()
      Show the contents that make up the key.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the object.
      See Also: