Package org.assertj.core.internal
Class DeepDifference
java.lang.Object
org.assertj.core.internal.DeepDifference
Tests two objects for differences by doing a 'deep' comparison.
Based on the deep equals implementation of https://github.com/jdereg/java-util
- Author:
- John DeRegnaucourt (john@cedarsoftware.com), Pascal Schumacher
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<DeepDifference.Difference> determineDifferences(Object a, Object b, Map<String, Comparator<?>> comparatorByPropertyOrField, TypeComparators comparatorByType) Compare two objects for differences by doing a 'deep' comparison.
-
Constructor Details
-
DeepDifference
public DeepDifference()
-
-
Method Details
-
determineDifferences
public static List<DeepDifference.Difference> determineDifferences(Object a, Object b, Map<String, Comparator<?>> comparatorByPropertyOrField, TypeComparators 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 comparecomparatorByPropertyOrField- comparators to compare properties or fields with the given namescomparatorByType- comparators to compare properties or fields with the given types- 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.
-