persolijn

an efficient router for busses
Log | Files | Refs

Passenger.java (958B)


      1 package osm.routing.entity;
      2 
      3 import java.util.AbstractList;
      4 
      5 public class Passenger<T> extends AbstractList<T> {
      6     public final Interval startTime;
      7     public final T startPoint;
      8     public final Interval targetTime;
      9     public final T targetPoint;
     10 
     11     public Passenger(T start, Interval startTime, T target, Interval targetTime) {
     12         startPoint = start;
     13         this.startTime = startTime;
     14         targetPoint = target;
     15         this.targetTime = targetTime;
     16     }
     17 
     18     public Passenger(T start, T target) {
     19         startPoint = start;
     20         this.startTime = null;
     21         targetPoint = target;
     22         this.targetTime = null;
     23     }
     24 
     25     @Override
     26     public T get(int i) {
     27         return switch (i) {
     28             case 0 -> startPoint;
     29             case 1 -> targetPoint;
     30             default -> throw new IndexOutOfBoundsException("Passenger can only hold 2 points");
     31         };
     32     }
     33 
     34     @Override
     35     public int size() {
     36         return 2;
     37     }
     38 }