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://github.com/peter-knoppers">Peter Knoppers</a>
15 * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
16 * @param numberOfLaneChanges required number of lane changes
17 * @param remainingDistance remaining distance
18 * @param deadEnd whether the need to change lane comes from a dead-end
19 * @param 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 required number of lane changes
28 * @param remainingDistance remaining distance
29 * @param deadEnd whether the need to change lane comes from a dead-end
30 * @param 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 @Override
39 public int compareTo(final LaneChangeInfo o)
40 {
41 if (o == null)
42 {
43 return 1;
44 }
45 if (o.remainingDistance.equals(this.remainingDistance))
46 {
47 return Integer.compare(this.numberOfLaneChanges, o.numberOfLaneChanges);
48 }
49 return this.remainingDistance.compareTo(o.remainingDistance);
50 }
51
52 }