determineDifferences
public static List<DeepDifference.Difference> determineDifferences(Object a,
Object b,
Map<String,Comparator<?>> comparatorByPropertyOrField,
Map<Class<?>,Comparator<?>> comparatorByType)
Compare two objects for differences by doing a 'deep' comparison. This will traverse the
Object graph and perform either a field-by-field comparison on each
object (if not .equals() method has been overridden from Object), or it
will call the customized .equals() method if it exists.
This method handles cycles correctly, for example A->B->C->A.
Suppose a and a' are two separate instances of the A with the same values
for all fields on A, B, and C. Then a.deepEquals(a') will return an empty list. It
uses cycle detection storing visited objects in a Set to prevent endless
loops.
- Parameters:
a
- Object one to compareb
- Object two to compare
- Returns:
- the list of differences found or an empty list if objects are equivalent.
Equivalent means that all field values of both subgraphs are the same,
either at the field level or via the respectively encountered overridden
.equals() methods during traversal.