org.test4j.hamcrest.matcher.property.comparator
类 ObjectComparator

java.lang.Object
  继承者 org.test4j.hamcrest.matcher.property.comparator.ObjectComparator
所有已实现的接口:
Comparator

public class ObjectComparator
extends Object
implements Comparator

Comparator for objects. This will compare all corresponding field values.


构造方法摘要
ObjectComparator()
           
 
方法摘要
 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.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

ObjectComparator

public ObjectComparator()
方法详细信息

canCompare

public boolean canCompare(Object left,
                          Object right)
Returns true if both objects are not null

指定者:
接口 Comparator 中的 canCompare
参数:
left - The left object
right - The right object
返回:
True if not null

compare

public Difference compare(Object left,
                          Object right,
                          boolean onlyFirstDifference,
                          ReflectionComparator reflectionComparator)
Compares the given objects by iterating over the fields and comparing the corresponding values. If both objects are of a different type, a difference is returned. The fields of the superclasses are also compared. Fields of java.lang classes are ignored. So for example fields of the Object class are not compared

指定者:
接口 Comparator 中的 compare
参数:
left - The left object, not null
right - The right object, not null
onlyFirstDifference - True if only the first difference should be returned
reflectionComparator - The root comparator for inner comparisons, not null
返回:
A ObjectDifference or null if both maps are equal

compareFields

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.

参数:
left - the left object for the comparison, not null
right - the right object for the comparison, not null
clazz - the type of the left object, not null
difference - root difference, not null
onlyFirstDifference - True if only the first difference should be returned
reflectionComparator - the reflection comparator, not null


Copyright © 2013. All rights reserved.