Record Class StopArrival

java.lang.Object
java.lang.Record
com.cta4j.bus.model.StopArrival
Record Components:
predictionType - the type of prediction (arrival or departure)
stopName - the name of the bus stop
stopId - the unique identifier of the bus stop
vehicleId - the unique identifier of the bus vehicle
distanceToStop - the distance from the bus to the stop in feet
route - the bus route identifier
routeDesignator - additional designator for the route, if any
routeDirection - the direction of the bus route (e.g., Northbound, Southbound)
destination - the final destination of the bus
arrivalTime - the predicted arrival time at the stop
delayed - indicates whether the bus is delayed

public record StopArrival(BusPredictionType predictionType, String stopName, String stopId, String vehicleId, BigInteger distanceToStop, String route, String routeDesignator, String routeDirection, String destination, Instant arrivalTime, Boolean delayed) extends Record
An arrival prediction for a bus at a specific stop.
  • Constructor Details

    • StopArrival

      public StopArrival(BusPredictionType predictionType, String stopName, String stopId, String vehicleId, BigInteger distanceToStop, String route, String routeDesignator, String routeDirection, String destination, Instant arrivalTime, Boolean delayed)
      Creates an instance of a StopArrival record class.
      Parameters:
      predictionType - the value for the predictionType record component
      stopName - the value for the stopName record component
      stopId - the value for the stopId record component
      vehicleId - the value for the vehicleId record component
      distanceToStop - the value for the distanceToStop record component
      route - the value for the route record component
      routeDesignator - the value for the routeDesignator record component
      routeDirection - the value for the routeDirection record component
      destination - the value for the destination record component
      arrivalTime - the value for the arrivalTime record component
      delayed - the value for the delayed record component
  • Method Details

    • etaMinutes

      public Long etaMinutes()
      Calculates the estimated time of arrival (ETA) in minutes from the current time to the predicted arrival time. If the arrival time is in the past, it returns 0.
      Returns:
      the ETA in minutes, or 0 if the arrival time is in the past
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • predictionType

      public BusPredictionType predictionType()
      Returns the value of the predictionType record component.
      Returns:
      the value of the predictionType record component
    • stopName

      public String stopName()
      Returns the value of the stopName record component.
      Returns:
      the value of the stopName record component
    • stopId

      public String stopId()
      Returns the value of the stopId record component.
      Returns:
      the value of the stopId record component
    • vehicleId

      public String vehicleId()
      Returns the value of the vehicleId record component.
      Returns:
      the value of the vehicleId record component
    • distanceToStop

      public BigInteger distanceToStop()
      Returns the value of the distanceToStop record component.
      Returns:
      the value of the distanceToStop record component
    • route

      public String route()
      Returns the value of the route record component.
      Returns:
      the value of the route record component
    • routeDesignator

      public String routeDesignator()
      Returns the value of the routeDesignator record component.
      Returns:
      the value of the routeDesignator record component
    • routeDirection

      public String routeDirection()
      Returns the value of the routeDirection record component.
      Returns:
      the value of the routeDirection record component
    • destination

      public String destination()
      Returns the value of the destination record component.
      Returns:
      the value of the destination record component
    • arrivalTime

      public Instant arrivalTime()
      Returns the value of the arrivalTime record component.
      Returns:
      the value of the arrivalTime record component
    • delayed

      public Boolean delayed()
      Returns the value of the delayed record component.
      Returns:
      the value of the delayed record component