java.lang.Object
java.lang.Record
com.cta4j.train.model.Train
- Record Components:
coordinates- the coordinates and heading of the trainarrivals- the list of upcoming train arrivals for the train
public record Train(TrainCoordinates coordinates, List<UpcomingTrainArrival> arrivals)
extends Record
A train currently in service.
-
Constructor Summary
ConstructorsConstructorDescriptionTrain(TrainCoordinates coordinates, List<UpcomingTrainArrival> arrivals) Creates an instance of aTrainrecord class. -
Method Summary
Modifier and TypeMethodDescriptionarrivals()Returns the value of thearrivalsrecord component.Returns the value of thecoordinatesrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Train
Creates an instance of aTrainrecord class.- Parameters:
coordinates- the value for thecoordinatesrecord componentarrivals- the value for thearrivalsrecord component
-
-
Method Details
-
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). -
coordinates
Returns the value of thecoordinatesrecord component.- Returns:
- the value of the
coordinatesrecord component
-
arrivals
Returns the value of thearrivalsrecord component.- Returns:
- the value of the
arrivalsrecord component
-