Package com.cta4j.bus.prediction.model
Record Class Prediction
java.lang.Object
java.lang.Record
com.cta4j.bus.prediction.model.Prediction
- Record Components:
predictionType- the type of this predictionstopId- the unique identifier of the stop for which this prediction was generatedstopName- the display name of the stop for which this prediction was generatedvehicleId- the unique identifier of the vehicle for which this prediction was generateddistanceToStop- the feet left to be traveled by the vehicle before it reaches the stop associated with this predictionroute- the alphanumeric designator of the route (e.g. "20" or "X20") for which this prediction was generatedrouteDesignator- the language-specific route designator of this prediction, intended for displayrouteDirection- the direction of travel of the route associated with this prediction (e.g. "Eastbound")destination- the final destination of the vehicle associated with this predictionarrivalTime- the predicted date and time (UTC) of a vehicle’s arrival or departure to the stop associated with this predictiondelayed- whether the vehicle associated with this prediction is currently delayedmetadata- 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 Summary
ConstructorsConstructorDescriptionPrediction(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 aPrediction. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thearrivalTimerecord component.@Nullable Booleandelayed()Returns the value of thedelayedrecord component.Returns the value of thedestinationrecord component.Returns the value of thedistanceToStoprecord component.final booleanIndicates whether some other object is "equal to" this one.longCalculates the estimated time of arrival (ETA) in minutes from the current time to the predicted arrival time.final inthashCode()Returns a hash code value for this object.metadata()Returns the value of themetadatarecord component.Returns the value of thepredictionTyperecord component.route()Returns the value of therouterecord component.Returns the value of therouteDesignatorrecord component.Returns the value of therouteDirectionrecord component.stopId()Returns the value of thestopIdrecord component.stopName()Returns the value of thestopNamerecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thevehicleIdrecord component.
-
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 aPrediction.- Parameters:
predictionType- the type of the predictionstopId- the unique identifier of the stop for which the prediction was generatedstopName- the display name of the stop for which the prediction was generatedvehicleId- the unique identifier of the vehicle for which the prediction was generateddistanceToStop- the feet left to be traveled by the vehicle before it reaches the stop associated with the predictionroute- the alphanumeric designator of the route (e.g. "20" or "X20") for which the prediction was generatedrouteDesignator- the language-specific route designator of the prediction, intended for displayrouteDirection- the direction of travel of the route associated with the prediction (e.g. "Eastbound")destination- the final destination of the vehicle associated with the predictionarrivalTime- the predicted date and time (UTC) of a vehicle’s arrival or departure to the stop associated with the predictiondelayed- whether the vehicle associated with the prediction is currently delayedmetadata- the metadata associated with the prediction- Throws:
NullPointerException- ifpredictionType,stopId,stopName,vehicleId,distanceToStop,route,routeDesignator,routeDirection,destination,arrivalTime, ormetadataisnull
-
-
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
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
predictionType
Returns the value of thepredictionTyperecord component.- Returns:
- the value of the
predictionTyperecord component
-
stopId
Returns the value of thestopIdrecord component.- Returns:
- the value of the
stopIdrecord component
-
stopName
Returns the value of thestopNamerecord component.- Returns:
- the value of the
stopNamerecord component
-
vehicleId
Returns the value of thevehicleIdrecord component.- Returns:
- the value of the
vehicleIdrecord component
-
distanceToStop
Returns the value of thedistanceToStoprecord component.- Returns:
- the value of the
distanceToStoprecord component
-
route
Returns the value of therouterecord component.- Returns:
- the value of the
routerecord component
-
routeDesignator
Returns the value of therouteDesignatorrecord component.- Returns:
- the value of the
routeDesignatorrecord component
-
routeDirection
Returns the value of therouteDirectionrecord component.- Returns:
- the value of the
routeDirectionrecord component
-
destination
Returns the value of thedestinationrecord component.- Returns:
- the value of the
destinationrecord component
-
arrivalTime
Returns the value of thearrivalTimerecord component.- Returns:
- the value of the
arrivalTimerecord component
-
delayed
Returns the value of thedelayedrecord component.- Returns:
- the value of the
delayedrecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-