import org.apache.commons.lang3.ObjectUtils; //导入方法依赖的package包/类
private void compareObjectsInternal(Object key, Object left, Object right, MutableCollection breaks) {
Class objectClass = left.getClass();
MutableCollection classCompareInfos = this.getClassCompareInfos(objectClass);
if (classCompareInfos.isEmpty()) {
if (!ObjectUtils.equals(left, right)) {
breaks.add(new FieldCompareBreak(objectClass, key, left, right, "this", left, right));
}
} else {
for (ClassCompareInfo classCompareInfo : classCompareInfos) {
for (Pair> functionPair : classCompareInfo.getCompareFunctions()) {
Function function = functionPair.getTwo();
Object leftFuncVal = function.valueOf(left);
Object rightFuncVal = function.valueOf(right);
if (leftFuncVal == null && rightFuncVal == null) {
continue; // no break - continue
} else if (leftFuncVal == null ^ rightFuncVal == null) { // XOR - if one of these is null, but not
// the other
breaks.add(new FieldCompareBreak(objectClass, key, left, right, functionPair.getOne(),
leftFuncVal, rightFuncVal));
} else {
MutableCollection funcClassCompareInfos = this.getClassCompareInfos(leftFuncVal
.getClass());
if (funcClassCompareInfos.isEmpty()) {
if (!ObjectUtils.equals(leftFuncVal, rightFuncVal)) {
breaks.add(new FieldCompareBreak(objectClass, key, left, right, functionPair.getOne(),
leftFuncVal, rightFuncVal));
}
} else {
this.compareObjectsInternal(key, leftFuncVal, rightFuncVal, breaks);
}
}
}
for (CollectionFieldCompareInfo collectionCompareInfo : classCompareInfo.getCollectionComparisonInfos()) {
this.compareCollectionsInternal(collectionCompareInfo.getElementClass()
, (Collection) collectionCompareInfo.getCollectionFieldFunction().valueOf(left)
, (Collection) collectionCompareInfo.getCollectionFieldFunction().valueOf(right)
, breaks);
}
}
}
}