|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectorg.test4j.hamcrest.matcher.property.reflection.ReflectionComparator
public class ReflectionComparator
A comparator for comparing two values by reflection.
The actual comparison of the values is implemented as a comparator chain. The chain is passed as an argument during the construction. Each of the comparators in the chain is able to compare some types of values. E.g. a CollectionComparator is able to compare collections, simple values such as integers are compared by the SimpleCasesComparator... A number of 'leniency levels' can also be added to the chain: e.g. the LenientOrderCollectionComparator ignores the actual ordering of 2 collections. The preferred way of creating new instances is by using the ReflectionComparatorFactory. This factory will make sure that a correct comparator chain is assembled. A readable report differences can be created using the DifferenceReport.
| 字段摘要 | |
|---|---|
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. |
| 构造方法摘要 | |
|---|---|
ReflectionComparator(List<Comparator> comparators)
Creates a comparator that will use the given chain. |
|
| 方法摘要 | |
|---|---|
protected Map<Object,Difference> |
getCachedDifference(Object left,
boolean onlyFirstDifference)
|
Difference |
getDifference(Object expectedValue,
Object actualValue)
Checks whether there is a difference between the left and right objects. |
Difference |
getDifference(Object expectedValue,
Object actualValue,
boolean onlyFirstDifference)
Checks whether there are differences between the left and right objects. |
boolean |
isEqual(Object expectedValue,
Object actualValue)
Checks whether there is no difference between the left and right objects. |
protected void |
saveResultInCache(Object left,
Map<Object,Difference> cachedResult,
boolean onlyFirstDifference)
|
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
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 null| 方法详细信息 |
|---|
public boolean isEqual(Object expectedValue,
Object actualValue)
expectedValue - the left instanceactualValue - the right instance
public Difference getDifference(Object expectedValue,
Object actualValue)
expectedValue - the left instanceactualValue - the right instance
public Difference getDifference(Object expectedValue,
Object actualValue,
boolean onlyFirstDifference)
expectedValue - the left instanceactualValue - the right instanceonlyFirstDifference - True if the comparison should stop at the first differnece
protected void saveResultInCache(Object left,
Map<Object,Difference> cachedResult,
boolean onlyFirstDifference)
protected Map<Object,Difference> getCachedDifference(Object left,
boolean onlyFirstDifference)
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||