Record Class Prediction

java.lang.Object
java.lang.Record
com.cta4j.bus.prediction.model.Prediction
Record Components:
predictionType - the type of this prediction
stopId - the unique identifier of the stop for which this prediction was generated
stopName - the display name of the stop for which this prediction was generated
vehicleId - the unique identifier of the vehicle for which this prediction was generated
distanceToStop - the feet left to be traveled by the vehicle before it reaches the stop associated with this prediction
route - the alphanumeric designator of the route (e.g. "20" or "X20") for which this prediction was generated
routeDesignator - the language-specific route designator of this prediction, intended for display
routeDirection - the direction of travel of the route associated with this prediction (e.g. "Eastbound")
destination - the final destination of the vehicle associated with this prediction
arrivalTime - the predicted date and time (UTC) of a vehicle’s arrival or departure to the stop associated with this prediction
delayed - whether the vehicle associated with this prediction is currently delayed
metadata - the metadata associated with this prediction

@NullMarked public record Prediction(PredictionType predictionType, String stopId, String stopName, String vehicleId, BigInteger distanceToStop, String route, String routeDesignator, String routeDirection, String destination, Instant arrivalTime, @Nullable Boolean delayed, PredictionMetadata metadata) extends Record
Represents a bus arrival prediction.
  • Constructor Details

    • Prediction

      public Prediction(PredictionType predictionType, String stopId, String stopName, String vehicleId, BigInteger distanceToStop, String route, String routeDesignator, String routeDirection, String destination, Instant arrivalTime, @Nullable Boolean delayed, PredictionMetadata metadata)
      Constructs a Prediction.
      Parameters:
      predictionType - the type of the prediction
      stopId - the unique identifier of the stop for which the prediction was generated
      stopName - the display name of the stop for which the prediction was generated
      vehicleId - the unique identifier of the vehicle for which the prediction was generated
      distanceToStop - the feet left to be traveled by the vehicle before it reaches the stop associated with the prediction
      route - the alphanumeric designator of the route (e.g. "20" or "X20") for which the prediction was generated
      routeDesignator - the language-specific route designator of the prediction, intended for display
      routeDirection - the direction of travel of the route associated with the prediction (e.g. "Eastbound")
      destination - the final destination of the vehicle associated with the prediction
      arrivalTime - the predicted date and time (UTC) of a vehicle’s arrival or departure to the stop associated with the prediction
      delayed - whether the vehicle associated with the prediction is currently delayed
      metadata - the metadata associated with the prediction
      Throws:
      NullPointerException - if predictionType, stopId, stopName, vehicleId, distanceToStop, route, routeDesignator, routeDirection, destination, arrivalTime, or metadata is null
  • Method Details

    • etaMinutes

      public long etaMinutes()
      Calculates the estimated time of arrival (ETA) in minutes from the current time to the predicted arrival time.
      Returns:
      the ETA in minutes; returns 0 if the predicted 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 PredictionType predictionType()
      Returns the value of the predictionType record component.
      Returns:
      the value of the predictionType record component
    • stopId

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

      public String stopName()
      Returns the value of the stopName record component.
      Returns:
      the value of the stopName 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 @Nullable Boolean delayed()
      Returns the value of the delayed record component.
      Returns:
      the value of the delayed record component
    • metadata

      public PredictionMetadata metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component