Package org.identityconnectors.common
Class EqualsHashCodeBuilder
- java.lang.Object
-
- org.identityconnectors.common.EqualsHashCodeBuilder
-
public final class EqualsHashCodeBuilder extends Object
Builder to simplify implementing theObject.equals(Object)andObject.hashCode()methods. This class usesArrayList's implementation ofArrayList.equals(Object)andArrayList.hashCode()and takes special care with deep arrays andCollectionbased objects.
-
-
Constructor Summary
Constructors Constructor Description EqualsHashCodeBuilder()Construct the builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EqualsHashCodeBuilderappend(Object object)Appends the field value to an ArrayList to help facilitate equality testing.voidappendBean(Object obj)This method will attempt to use reflection to get all the properties that make up the identity of the object.booleanequals(Object obj)Determine equality based on the value of the members append to the builder.inthashCode()Determine the hashcode based on the various members.StringtoString()Show the contents that make up the key.
-
-
-
Method Detail
-
append
public EqualsHashCodeBuilder append(Object object)
Appends the field value to an ArrayList to help facilitate equality testing.- Parameters:
object-- Returns:
- 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 willappend(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:
equalsin classObject- Parameters:
obj- the reference object with which to compare.- Returns:
trueif this object is the same as the obj argument;falseotherwise.- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
Determine the hashcode based on the various members.- Overrides:
hashCodein classObject- Returns:
- a hash code value for this object.
- See Also:
Object.hashCode()
-
toString
public String toString()
Show the contents that make up the key.- Overrides:
toStringin classObject- Returns:
- a string representation of the object.
- See Also:
Object.toString()
-
-