InfrastructureLaneChangeInfoToledo.java

  1. package org.opentrafficsim.road.gtu.lane.tactical.toledo;

  2. import java.io.Serializable;

  3. import org.djutils.exceptions.Throw;
  4. import org.opentrafficsim.core.gtu.GTUException;
  5. import org.opentrafficsim.core.gtu.RelativePosition;
  6. import org.opentrafficsim.core.network.LateralDirectionality;
  7. import org.opentrafficsim.road.gtu.lane.perception.InfrastructureLaneChangeInfo;
  8. import org.opentrafficsim.road.gtu.lane.perception.LaneStructureRecord;

  9. /**
  10.  * <p>
  11.  * Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  12.  * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
  13.  * <p>
  14.  * @version $Revision$, $LastChangedDate$, by $Author$, initial version Jul 28, 2016 <br>
  15.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  16.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  17.  * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
  18.  */

  19. public class InfrastructureLaneChangeInfoToledo extends InfrastructureLaneChangeInfo implements Serializable
  20. {

  21.     /** */
  22.     private static final long serialVersionUID = 20160811L;

  23.     /** Split number, 0 if this info does not regard a split. */
  24.     private final int splitNumber;

  25.     /**
  26.      * @param requiredNumberOfLaneChanges int; number of lane changes
  27.      * @param record LaneStructureRecord; record
  28.      * @param splitNumber int; number of the split along the road
  29.      * @throws GTUException if the split number is below 1
  30.      */
  31.     public InfrastructureLaneChangeInfoToledo(final int requiredNumberOfLaneChanges, final LaneStructureRecord record,
  32.             final int splitNumber) throws GTUException
  33.     {
  34.         super(requiredNumberOfLaneChanges, record, RelativePosition.REFERENCE_POSITION, splitNumber > 0,
  35.                 LateralDirectionality.NONE);
  36.         Throw.when(splitNumber <= 0, GTUException.class, "Split number should be at least 1.");
  37.         this.splitNumber = splitNumber;
  38.     }

  39.     /**
  40.      * Returns whether this information regards a split in the road.
  41.      * @return whether this information regards a split in the road
  42.      */
  43.     public final boolean forSplit()
  44.     {
  45.         return this.splitNumber > 0;
  46.     }

  47.     /**
  48.      * Returns the split number.
  49.      * @return split number
  50.      */
  51.     public final int getSplitNumber()
  52.     {
  53.         return this.splitNumber;
  54.     }

  55.     /** {@inheritDoc} */
  56.     @Override
  57.     public final String toString()
  58.     {
  59.         return "InfrastructureLaneChangeInfoToledo [requiredNumberOfLaneChanges=" + getRequiredNumberOfLaneChanges()
  60.                 + ", remainingDistance=" + getRemainingDistance() + ", split=" + this.splitNumber + "]";
  61.     }
  62. }