LaneBasedGtuTemplateDistribution.java

  1. package org.opentrafficsim.road.gtu.generator.characteristics;

  2. import java.io.Serializable;

  3. import org.opentrafficsim.base.parameters.ParameterException;
  4. import org.opentrafficsim.core.distributions.Distribution;
  5. import org.opentrafficsim.core.distributions.ProbabilityException;

  6. /**
  7.  * Distribution of LaneBasedTemplateGTUType.
  8.  * <p>
  9.  * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  10.  * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  11.  * </p>
  12.  * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
  13.  * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
  14.  */
  15. public class LaneBasedGtuTemplateDistribution implements LaneBasedGtuCharacteristicsGenerator, Serializable
  16. {

  17.     /** */
  18.     private static final long serialVersionUID = 20160000L;

  19.     /** The Distribution of lane based template GTU types. */
  20.     private final Distribution<LaneBasedGtuTemplate> distribution;

  21.     /**
  22.      * Construct a new LaneBasedTemplateGTUTypeDistribution.
  23.      * @param distributionOfLanebasedTemplateGTUType Distribution&lt;LaneBasedTemplateGTUType&gt;; the distribution of
  24.      *            LaneBasedTemplateGTUTypes
  25.      */
  26.     public LaneBasedGtuTemplateDistribution(
  27.             final Distribution<LaneBasedGtuTemplate> distributionOfLanebasedTemplateGTUType)
  28.     {
  29.         this.distribution = distributionOfLanebasedTemplateGTUType;
  30.     }

  31.     /** {@inheritDoc} */
  32.     @Override
  33.     public final LaneBasedGtuCharacteristics draw() throws ProbabilityException, ParameterException
  34.     {
  35.         return this.distribution.draw().draw();
  36.     }

  37.     /** {@inheritDoc} */
  38.     @Override
  39.     public final String toString()
  40.     {
  41.         return "LaneBasedTemplateGTUTypeDistribution [distribution=" + this.distribution + "]";
  42.     }

  43. }