Package com.cta4j.bus.vehicle.model
Record Class Vehicle
java.lang.Object
java.lang.Record
com.cta4j.bus.vehicle.model.Vehicle
- Record Components:
id- the unique identifier of this vehicleroute- the alphanumeric designator of the route that is currently being serviced by this vehicledestination- the destination of the trip being serviced by this vehicle (e.g. "Austin")coordinates- the current coordinates of this vehicledelayed- whether this vehicle is currently delayedmetadata- 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 Summary
ConstructorsConstructorDescriptionVehicle(String id, String route, String destination, Coordinates coordinates, boolean delayed, VehicleMetadata metadata) Constructs aVehicle. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecoordinatesrecord component.booleandelayed()Returns the value of thedelayedrecord component.Returns the value of thedestinationrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.metadata()Returns the value of themetadatarecord component.route()Returns the value of therouterecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Vehicle
public Vehicle(String id, String route, String destination, Coordinates coordinates, boolean delayed, VehicleMetadata metadata) Constructs aVehicle.- Parameters:
id- the unique identifier of the vehicleroute- the alphanumeric designator of the route that is currently being serviced by the vehicledestination- the destination of the trip being serviced by the vehicle (e.g. "Austin")coordinates- the current coordinates of the vehicledelayed- whether the vehicle is currently delayedmetadata- the metadata associated with the vehicle- Throws:
NullPointerException- ifid,route,destination,coordinates, ormetadataisnull
-
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
route
Returns the value of therouterecord component.- Returns:
- the value of the
routerecord component
-
destination
Returns the value of thedestinationrecord component.- Returns:
- the value of the
destinationrecord component
-
coordinates
Returns the value of thecoordinatesrecord component.- Returns:
- the value of the
coordinatesrecord component
-
delayed
public boolean 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
-