org.unitils.reflectionassert.comparator.impl
Class LenientDatesComparator
java.lang.Object
org.unitils.reflectionassert.comparator.impl.LenientDatesComparator
- All Implemented Interfaces:
- Comparator
public class LenientDatesComparator
- extends Object
- implements Comparator
Comparator that checks whether 2 dates are both null or not null, the actual time-value is not compared.
This can be useful when the actual time/date is not known is advance but you still want to check whether
a value has been set or not. E.g. a last modification timestamp in the databsse.
- Author:
- Tim Ducheyne, Filip Neven
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LenientDatesComparator
public LenientDatesComparator()
canCompare
public boolean canCompare(Object left,
Object right)
- Returns true if both objects are null or both objects are Date instances.
- Specified by:
canCompare
in interface Comparator
- Parameters:
left
- The left objectright
- The right object
- Returns:
- True if null or dates
compare
public Difference compare(Object left,
Object right,
boolean onlyFirstDifference,
ReflectionComparator reflectionComparator)
- Compares the given dates.
- Specified by:
compare
in interface Comparator
- Parameters:
left
- The left dateright
- The right dateonlyFirstDifference
- True if only the first difference should be returnedreflectionComparator
- The root comparator for inner comparisons, not null
- Returns:
- A difference if one of the dates is null and the other one not, else null
Copyright © 2011. All Rights Reserved.