2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.onebusaway.internal.handler;
16 * The {@link ObaStopArrivalResponse} is a representation of the OneBusAway response for requesting a stops arrival
20 * "http://developer.onebusaway.org/modules/onebusaway-application-modules/current/api/where/methods/arrivals-and-departures-for-stop.html">arrivals-and-departures-for-stop
23 * @author Shawn Wilsher - Initial contribution
25 public class ObaStopArrivalResponse {
26 public long currentTime;
34 public ArrivalAndDeparture[] arrivalsAndDepartures;
37 public class ArrivalAndDeparture implements Comparable<ArrivalAndDeparture> {
38 public boolean predicted;
39 public long predictedArrivalTime;
40 public long predictedDepartureTime;
41 public long scheduledArrivalTime;
42 public long scheduledDepartureTime;
43 public String routeLongName;
44 public String routeShortName;
45 public String routeId;
47 public String tripHeadsign;
50 * Assumes other is for the same routeId and stopId. Sorts based on arrival time.
53 public int compareTo(ArrivalAndDeparture other) {
54 // Prefer predicated over scheduled times for order
55 return (int) ((predicted ? predictedArrivalTime : scheduledArrivalTime)
56 - (other.predicted ? other.predictedArrivalTime : other.scheduledArrivalTime));