org.specrunner.comparators.core
Class AbstractComparatorTime

java.lang.Object
  extended by org.specrunner.comparators.core.ComparatorDefault
      extended by org.specrunner.comparators.core.AbstractComparatorTime
All Implemented Interfaces:
Serializable, Comparator<Object>, IComparator, IResetable
Direct Known Subclasses:
ComparatorDate, ComparatorJodatime, ComparatorTime, ComparatorTimestamp

public abstract class AbstractComparatorTime
extends ComparatorDefault

Abstract comparator of time objects.

Author:
Thiago Santos
See Also:
Serialized Form

Field Summary
static String FEATURE_TOLERANCE
          Feature to set time tolerance.
 
Constructor Summary
AbstractComparatorTime()
           
 
Method Summary
protected  boolean compare(Long expected, Long received)
          Compare the expected and received.
 int compare(Object o1, Object o2)
           
protected abstract  Long getMillis(Object obj)
          Get the corresponding time information in milliseconds.
 Long getTolerance()
          Get the time tolerance.
 void initialize()
          Initialize something.
 boolean match(Object expected, Object received)
          Says if two objects can be considered equals.
 void setTolerance(Long tolerance)
          Set time tolerance.
 
Methods inherited from class org.specrunner.comparators.core.ComparatorDefault
getType, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

FEATURE_TOLERANCE

public static final String FEATURE_TOLERANCE
Feature to set time tolerance.

Constructor Detail

AbstractComparatorTime

public AbstractComparatorTime()
Method Detail

initialize

public void initialize()
Description copied from interface: IResetable
Initialize something.

Specified by:
initialize in interface IResetable
Overrides:
initialize in class ComparatorDefault

getTolerance

public Long getTolerance()
Get the time tolerance.

Returns:
The time.

setTolerance

public void setTolerance(Long tolerance)
Set time tolerance.

Parameters:
tolerance - The tolerance.

match

public boolean match(Object expected,
                     Object received)
Description copied from interface: IComparator
Says if two objects can be considered equals.

Specified by:
match in interface IComparator
Overrides:
match in class ComparatorDefault
Parameters:
expected - The expected value.
received - The received value.
Returns:
true, if they are equal, false, otherwise.

getMillis

protected abstract Long getMillis(Object obj)
Get the corresponding time information in milliseconds.

Parameters:
obj - The time object.
Returns:
The time in milliseconds corresponding to the object.

compare

protected boolean compare(Long expected,
                          Long received)
Compare the expected and received.

Parameters:
expected - The expected time.
received - The received time.
Returns:
true, if acceptable, false, otherwise.

compare

public int compare(Object o1,
                   Object o2)
Specified by:
compare in interface Comparator<Object>
Overrides:
compare in class ComparatorDefault


Copyright © 2014. All rights reserved.