Record Class Vehicle

java.lang.Object
java.lang.Record
com.cta4j.bus.vehicle.model.Vehicle
Record Components:
id - the unique identifier of this vehicle
route - the alphanumeric designator of the route that is currently being serviced by this vehicle
destination - the destination of the trip being serviced by this vehicle (e.g. "Austin")
coordinates - the current coordinates of this vehicle
delayed - whether this vehicle is currently delayed
metadata - the metadata associated with this vehicle

@NullMarked public record Vehicle(String id, String route, String destination, Coordinates coordinates, boolean delayed, VehicleMetadata metadata) extends Record
Represents a vehicle.
  • Constructor Details

    • Vehicle

      public Vehicle(String id, String route, String destination, Coordinates coordinates, boolean delayed, VehicleMetadata metadata)
      Constructs a Vehicle.
      Parameters:
      id - the unique identifier of the vehicle
      route - the alphanumeric designator of the route that is currently being serviced by the vehicle
      destination - the destination of the trip being serviced by the vehicle (e.g. "Austin")
      coordinates - the current coordinates of the vehicle
      delayed - whether the vehicle is currently delayed
      metadata - the metadata associated with the vehicle
      Throws:
      NullPointerException - if id, route, destination, coordinates, or metadata is 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.
    • id

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

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

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

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

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

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