View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical.toledo;
2   
3   import java.io.Serializable;
4   
5   import org.djutils.exceptions.Throw;
6   import org.opentrafficsim.core.gtu.GtuException;
7   import org.opentrafficsim.core.gtu.RelativePosition;
8   import org.opentrafficsim.core.network.LateralDirectionality;
9   import org.opentrafficsim.road.gtu.lane.perception.InfrastructureLaneChangeInfo;
10  import org.opentrafficsim.road.gtu.lane.perception.LaneStructureRecord;
11  
12  /**
13   * <p>
14   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
16   * </p>
17   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
18   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
19   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
20   */
21  
22  public class InfrastructureLaneChangeInfoToledo extends InfrastructureLaneChangeInfo implements Serializable
23  {
24  
25      /** */
26      private static final long serialVersionUID = 20160811L;
27  
28      /** Split number, 0 if this info does not regard a split. */
29      private final int splitNumber;
30  
31      /**
32       * @param requiredNumberOfLaneChanges int; number of lane changes
33       * @param record LaneStructureRecord; record
34       * @param splitNumber int; number of the split along the road
35       * @throws GtuException if the split number is below 1
36       */
37      public InfrastructureLaneChangeInfoToledo(final int requiredNumberOfLaneChanges, final LaneStructureRecord record,
38              final int splitNumber) throws GtuException
39      {
40          super(requiredNumberOfLaneChanges, record, RelativePosition.REFERENCE_POSITION, splitNumber > 0,
41                  LateralDirectionality.NONE);
42          Throw.when(splitNumber <= 0, GtuException.class, "Split number should be at least 1.");
43          this.splitNumber = splitNumber;
44      }
45  
46      /**
47       * Returns whether this information regards a split in the road.
48       * @return whether this information regards a split in the road
49       */
50      public final boolean forSplit()
51      {
52          return this.splitNumber > 0;
53      }
54  
55      /**
56       * Returns the split number.
57       * @return split number
58       */
59      public final int getSplitNumber()
60      {
61          return this.splitNumber;
62      }
63  
64      /** {@inheritDoc} */
65      @Override
66      public final String toString()
67      {
68          return "InfrastructureLaneChangeInfoToledo [requiredNumberOfLaneChanges=" + getRequiredNumberOfLaneChanges()
69                  + ", remainingDistance=" + getRemainingDistance() + ", split=" + this.splitNumber + "]";
70      }
71  }