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-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
16   * <p>
17   * @version $Revision$, $LastChangedDate$, by $Author$, initial version Jul 28, 2016 <br>
18   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
19   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
20   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
21   */
22  
23  public class InfrastructureLaneChangeInfoToledo extends InfrastructureLaneChangeInfo implements Serializable
24  {
25  
26      /** */
27      private static final long serialVersionUID = 20160811L;
28  
29      /** Split number, 0 if this info does not regard a split. */
30      private final int splitNumber;
31  
32      /**
33       * @param requiredNumberOfLaneChanges int; number of lane changes
34       * @param record LaneStructureRecord; record
35       * @param splitNumber int; number of the split along the road
36       * @throws GTUException if the split number is below 1
37       */
38      public InfrastructureLaneChangeInfoToledo(final int requiredNumberOfLaneChanges, final LaneStructureRecord record,
39              final int splitNumber) throws GTUException
40      {
41          super(requiredNumberOfLaneChanges, record, RelativePosition.REFERENCE_POSITION, splitNumber > 0,
42                  LateralDirectionality.NONE);
43          Throw.when(splitNumber <= 0, GTUException.class, "Split number should be at least 1.");
44          this.splitNumber = splitNumber;
45      }
46  
47      /**
48       * Returns whether this information regards a split in the road.
49       * @return whether this information regards a split in the road
50       */
51      public final boolean forSplit()
52      {
53          return this.splitNumber > 0;
54      }
55  
56      /**
57       * Returns the split number.
58       * @return split number
59       */
60      public final int getSplitNumber()
61      {
62          return this.splitNumber;
63      }
64  
65      /** {@inheritDoc} */
66      @Override
67      public final String toString()
68      {
69          return "InfrastructureLaneChangeInfoToledo [requiredNumberOfLaneChanges=" + getRequiredNumberOfLaneChanges()
70                  + ", remainingDistance=" + getRemainingDistance() + ", split=" + this.splitNumber + "]";
71      }
72  }