public class ObjectComparator extends Object implements Comparator
| Constructor and Description |
|---|
ObjectComparator() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canCompare(Object left,
Object right)
Returns true if both objects are not null
|
Difference |
compare(Object left,
Object right,
boolean onlyFirstDifference,
ReflectionComparator reflectionComparator)
Compares the given objects by iterating over the fields and comparing the corresponding values.
|
protected void |
compareFields(Object left,
Object right,
Class<?> clazz,
ObjectDifference difference,
boolean onlyFirstDifference,
ReflectionComparator reflectionComparator)
Compares the values of all fields in the given objects by use of reflection.
|
public boolean canCompare(Object left, Object right)
canCompare in interface Comparatorleft - The left objectright - The right objectpublic Difference compare(Object left, Object right, boolean onlyFirstDifference, ReflectionComparator reflectionComparator)
compare in interface Comparatorleft - The left object, not nullright - The right object, not nullonlyFirstDifference - True if only the first difference should be returnedreflectionComparator - The root comparator for inner comparisons, not nullprotected void compareFields(Object left, Object right, Class<?> clazz, ObjectDifference difference, boolean onlyFirstDifference, ReflectionComparator reflectionComparator)
left - the left object for the comparison, not nullright - the right object for the comparison, not nullclazz - the type of the left object, not nulldifference - root difference, not nullonlyFirstDifference - True if only the first difference should be returnedreflectionComparator - the reflection comparator, not nullCopyright © 2016. All Rights Reserved.