public class ReflectionComparator extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Map<Object,Map<Object,Difference>> |
allDifferencesCachedResults |
protected List<Comparator> |
comparators
The comparator chain.
|
protected Map<Object,Map<Object,Difference>> |
firstDifferenceCachedResults
A cache of results, so that comparisons are only performed once and infinite loops because of cycles are avoided
A different cache is used dependent on whether only the first difference is required or whether we need all
differences, since the resulting
Difference objects differ. |
| Constructor and Description |
|---|
ReflectionComparator(List<Comparator> comparators)
Creates a comparator that will use the given chain.
|
| Modifier and Type | Method and Description |
|---|---|
protected Map<Object,Difference> |
getCachedDifference(Object left,
boolean onlyFirstDifference) |
Difference |
getDifference(Object left,
Object right)
Checks whether there is a difference between the left and right objects.
|
Difference |
getDifference(Object left,
Object right,
boolean onlyFirstDifference)
Checks whether there are differences between the left and right objects.
|
boolean |
isEqual(Object left,
Object right)
Checks whether there is no difference between the left and right objects.
|
protected void |
saveResultInCache(Object left,
Map<Object,Difference> cachedResult,
boolean onlyFirstDifference) |
protected List<Comparator> comparators
protected Map<Object,Map<Object,Difference>> firstDifferenceCachedResults
Difference objects differ.protected Map<Object,Map<Object,Difference>> allDifferencesCachedResults
public ReflectionComparator(List<Comparator> comparators)
comparators - The comparator chain, not nullpublic boolean isEqual(Object left, Object right)
left - the left instanceright - the right instancepublic Difference getDifference(Object left, Object right)
left - the left instanceright - the right instancepublic Difference getDifference(Object left, Object right, boolean onlyFirstDifference)
left - the left instanceright - the right instanceonlyFirstDifference - True if the comparison should stop at the first differneceprotected void saveResultInCache(Object left, Map<Object,Difference> cachedResult, boolean onlyFirstDifference)
protected Map<Object,Difference> getCachedDifference(Object left, boolean onlyFirstDifference)
Copyright © 2016. All Rights Reserved.