com.dlsc.flexgantt.model
Class TimeSpanComparator

java.lang.Object
  extended by com.dlsc.flexgantt.model.TimeSpanComparator
All Implemented Interfaces:
java.util.Comparator<ITimeSpan>

public class TimeSpanComparator
extends java.lang.Object
implements java.util.Comparator<ITimeSpan>

A specialized Comparator that is capable of comparing two time spans with each other. This class comes in handy when tryin to sort collections of time spans.

Since:
1.0
Author:
Dirk Lemmermann
See Also:
Collections.sort(java.util.List, Comparator)

Constructor Summary
TimeSpanComparator()
           
 
Method Summary
 int compare(ITimeSpan span1, ITimeSpan span2)
          Compares two time spans with each other.
 
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
 

Constructor Detail

TimeSpanComparator

public TimeSpanComparator()
Method Detail

compare

public int compare(ITimeSpan span1,
                   ITimeSpan span2)
Compares two time spans with each other. This method will simply call Comparable.compareTo(Object) on the first time span passing in the second span as an argument.

Specified by:
compare in interface java.util.Comparator<ITimeSpan>
Parameters:
span1 - the first span to compare
span2 - the second span to compare
Returns:
-1, 0, +1 depending on whether the first span starts before, at the same time, or after the second span
Since:
1.0
See Also:
Comparator.compare(java.lang.Object, java.lang.Object)