Record Class Leg

java.lang.Object
java.lang.Record
id.klacak.bus_navigator.Leg
Record Components:
boardStop - stop where the passenger boards
route - route used for the ride
alightStop - stop where the passenger leaves the route

public record Leg(Stop boardStop, Route route, Stop alightStop) extends Record
A single ride on a route from one stop to another.
  • Constructor Details

    • Leg

      public Leg(Stop boardStop, Route route, Stop alightStop)
      Creates an instance of a Leg record class.
      Parameters:
      boardStop - the value for the boardStop record component
      route - the value for the route record component
      alightStop - the value for the alightStop record component
  • Method Details

    • toString

      public String toString()
      Formats this ride as a short Indonesian-language itinerary description.
      Specified by:
      toString in class Record
      Returns:
      formatted boarding stop, route, and alighting stop
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • boardStop

      public Stop boardStop()
      Returns the value of the boardStop record component.
      Returns:
      the value of the boardStop record component
    • route

      public Route route()
      Returns the value of the route record component.
      Returns:
      the value of the route record component
    • alightStop

      public Stop alightStop()
      Returns the value of the alightStop record component.
      Returns:
      the value of the alightStop record component