org.unitils.reflectionassert.comparator.impl
Class CollectionComparator
java.lang.Object
org.unitils.reflectionassert.comparator.impl.CollectionComparator
- All Implemented Interfaces:
- Comparator
public class CollectionComparator
- extends Object
- implements Comparator
Comparator for collections and arrays.
All elements are compared in the same order, i.e. element 1 of the left collection with element 1 of the
right collection and so on.
- Author:
- Tim Ducheyne, Filip Neven
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CollectionComparator
public CollectionComparator()
canCompare
public boolean canCompare(Object left,
Object right)
- Returns true when both objects are arrays or collections.
- Specified by:
canCompare in interface Comparator
- Parameters:
left - The left objectright - The right object
- Returns:
- True in case of arrays/collections
compare
public Difference compare(Object left,
Object right,
boolean onlyFirstDifference,
ReflectionComparator reflectionComparator)
- Compared the given collections/arrays.
- Specified by:
compare in interface Comparator
- Parameters:
left - The left collection/array, not nullright - The right collection/array, not nullonlyFirstDifference - True if only the first difference should be returnedreflectionComparator - The root comparator for inner comparisons, not null
- Returns:
- A CollectionDifference or null if both collections are equal
Copyright © 2011. All Rights Reserved.