org.unitils.reflectionassert.comparator.impl
Class MapComparator
java.lang.Object
org.unitils.reflectionassert.comparator.impl.MapComparator
- All Implemented Interfaces:
- Comparator
public class MapComparator
- extends Object
- implements Comparator
Comparator for maps. This will compare all values with corresponding keys.
- Author:
- Tim Ducheyne, Filip Neven
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MapComparator
public MapComparator()
canCompare
public boolean canCompare(Object left,
Object right)
- Returns true when both values are not null and instance of Map
- Specified by:
canCompare
in interface Comparator
- Parameters:
left
- The left objectright
- The right object
- Returns:
- True for maps
compare
public Difference compare(Object left,
Object right,
boolean onlyFirstDifference,
ReflectionComparator reflectionComparator)
- Compares the given maps by looping over the keys and comparing their values.
The key values are compared using a strict reflection comparison.
- Specified by:
compare
in interface Comparator
- Parameters:
left
- The left map, not nullright
- The right map, not nullonlyFirstDifference
- True if only the first difference should be returnedreflectionComparator
- The root comparator for inner comparisons, not null
- Returns:
- A MapDifference or null if both maps are equal
Copyright © 2011. All Rights Reserved.