Record Class LocationTrain

java.lang.Object
java.lang.Record
com.cta4j.train.location.model.LocationTrain
Record Components:
run - the run number of this train
destinationStationId - the unique identifier of the destination station for this train
destinationName - the display name of the destination station for this train
direction - the direction of travel of this train
nextStationId - the unique identifier of the next station for this train
nextStopId - the unique identifier of the next stop for this train
nextStationName - the display name of the next station for this train
predictionTime - the date and time (UTC) this location was generated
arrivalTime - the date and time (UTC) of this train's arrival at the next stop
approaching - whether this train is currently approaching the next stop
delayed - whether this train is currently delayed
flags - the flags associated with this train, if applicable
coordinates - the current coordinates of this train

@NullMarked public record LocationTrain(String run, String destinationStationId, String destinationName, TrainDirection direction, String nextStationId, String nextStopId, String nextStationName, Instant predictionTime, Instant arrivalTime, boolean approaching, boolean delayed, @Nullable String flags, Coordinates coordinates) extends Record
Represents the location of a train on a route.
  • Constructor Details

    • LocationTrain

      public LocationTrain(String run, String destinationStationId, String destinationName, TrainDirection direction, String nextStationId, String nextStopId, String nextStationName, Instant predictionTime, Instant arrivalTime, boolean approaching, boolean delayed, @Nullable String flags, Coordinates coordinates)
      Constructs a LocationTrain.
      Parameters:
      run - the run number of the train
      destinationStationId - the unique identifier of the destination station for the train
      destinationName - the display name of the destination station for the train
      direction - the direction of travel of the train
      nextStationId - the unique identifier of the next station for the train
      nextStopId - the unique identifier of the next stop for the train
      nextStationName - the display name of the next station for the train
      predictionTime - the date and time (UTC) the location was generated
      arrivalTime - the date and time (UTC) of the train's arrival at the next stop
      approaching - whether the train is currently approaching the next stop
      delayed - whether the train is currently delayed
      flags - the flags associated with the train, if applicable
      coordinates - the current coordinates of the train
      Throws:
      NullPointerException - if run, destinationStationId, destinationName, direction, nextStationId, nextStopId, nextStationName, predictionTime, arrivalTime, or coordinates are null
  • Method Details

    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • run

      public String run()
      Returns the value of the run record component.
      Returns:
      the value of the run record component
    • destinationStationId

      public String destinationStationId()
      Returns the value of the destinationStationId record component.
      Returns:
      the value of the destinationStationId record component
    • destinationName

      public String destinationName()
      Returns the value of the destinationName record component.
      Returns:
      the value of the destinationName record component
    • direction

      public TrainDirection direction()
      Returns the value of the direction record component.
      Returns:
      the value of the direction record component
    • nextStationId

      public String nextStationId()
      Returns the value of the nextStationId record component.
      Returns:
      the value of the nextStationId record component
    • nextStopId

      public String nextStopId()
      Returns the value of the nextStopId record component.
      Returns:
      the value of the nextStopId record component
    • nextStationName

      public String nextStationName()
      Returns the value of the nextStationName record component.
      Returns:
      the value of the nextStationName record component
    • predictionTime

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

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

      public boolean approaching()
      Returns the value of the approaching record component.
      Returns:
      the value of the approaching record component
    • delayed

      public boolean delayed()
      Returns the value of the delayed record component.
      Returns:
      the value of the delayed record component
    • flags

      public @Nullable String flags()
      Returns the value of the flags record component.
      Returns:
      the value of the flags record component
    • coordinates

      public Coordinates coordinates()
      Returns the value of the coordinates record component.
      Returns:
      the value of the coordinates record component