View Javadoc

1   /*
2    * Copyright 2011-2013 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  package org.kuali.mobility.bus.util;
16  
17  import java.io.Serializable;
18  import java.util.Comparator;
19  import org.kuali.mobility.bus.entity.ScheduledStop;
20  
21  /**
22   *
23   * @author Joe Swanson <joseswan@umich.edu>
24   */
25  public final class ScheduledStopComparitor implements Comparator<ScheduledStop>, Serializable {
26  
27      public int compare( final ScheduledStop stopA, final ScheduledStop stopB ) {
28          int compValue;
29  
30          if( null == stopA ) {
31              compValue = -5;
32          } else if( null == stopB ) {
33              compValue = 8;
34          } else {
35              compValue = (int) (stopA.getTimeToArrival() - stopB.getTimeToArrival());
36          }
37          return compValue;
38      }
39  }