View Javadoc
1   package org.opentrafficsim.road.network;
2   
3   import org.djunits.value.vdouble.scalar.Length;
4   import org.djutils.exceptions.Throw;
5   import org.opentrafficsim.core.network.LateralDirectionality;
6   
7   /**
8    * Lane change info.
9    * <p>
10   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
11   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
12   * </p>
13   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
14   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
15   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
16   * @param numberOfLaneChanges int; required number of lane changes
17   * @param remainingDistance Length; remaining distance
18   * @param deadEnd boolean; whether the need to change lane comes from a dead-end
19   * @param lateralDirectionality LateralDirectionality; lateral directionality of required lane changes
20   */
21  public record LaneChangeInfo(int numberOfLaneChanges, Length remainingDistance, boolean deadEnd,
22          LateralDirectionality lateralDirectionality) implements Comparable<LaneChangeInfo>
23  {
24  
25      /**
26       * Constructor.
27       * @param numberOfLaneChanges int; required number of lane changes
28       * @param remainingDistance Length; remaining distance
29       * @param deadEnd boolean; whether the need to change lane comes from a dead-end
30       * @param lateralDirectionality LateralDirectionality; lateral directionality of required lane changes
31       */
32      public LaneChangeInfo
33      {
34          Throw.whenNull(remainingDistance, "remainingDistance may not be null");
35          Throw.whenNull(lateralDirectionality, "lat may not be null");
36      }
37  
38      /** {@inheritDoc} */
39      @Override
40      public int compareTo(final LaneChangeInfo o)
41      {
42          if (o == null)
43          {
44              return 1;
45          }
46          if (o.remainingDistance.equals(this.remainingDistance))
47          {
48              return Integer.compare(this.numberOfLaneChanges, o.numberOfLaneChanges);
49          }
50          return this.remainingDistance.compareTo(o.remainingDistance);
51      }
52  
53  }