org.unitils.reflectionassert.comparator.impl
Class SimpleCasesComparator
java.lang.Object
org.unitils.reflectionassert.comparator.impl.SimpleCasesComparator
- All Implemented Interfaces:
- Comparator
public class SimpleCasesComparator
- extends Object
- implements Comparator
Comparator for simple cases.
Following cases are handled: left and right are the same instance, left or right have a null value,
left or right are enumerations, left or right are java.lang classes and
left or right are of type Character or Number
- Author:
- Tim Ducheyne, Filip Neven
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SimpleCasesComparator
public SimpleCasesComparator()
canCompare
public boolean canCompare(Object left,
Object right)
- Returns true if both object are the same instance, have a null value, are an Enum/Number/Character or
are a java.lang type.
- Specified by:
canCompare
in interface Comparator
- Parameters:
left
- The left objectright
- The right object
- Returns:
- True for simple cases
compare
public Difference compare(Object left,
Object right,
boolean onlyFirstDifference,
ReflectionComparator reflectionComparator)
- Compares the given values.
- Specified by:
compare
in interface Comparator
- Parameters:
left
- The left valueright
- The right valueonlyFirstDifference
- True if only the first difference should be returnedreflectionComparator
- The root comparator for inner comparisons, not null
- Returns:
- A Difference if both values are different, null otherwise
Copyright © 2011. All Rights Reserved.