TaskSupplier.java

  1. package org.opentrafficsim.road.gtu.lane.perception.mental.sdm;

  2. import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
  3. import org.opentrafficsim.road.gtu.lane.perception.mental.ConstantTask;
  4. import org.opentrafficsim.road.gtu.lane.perception.mental.Task;

  5. /**
  6.  * Supplies a Task for within Fullers model.
  7.  * <p>
  8.  * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  9.  * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  10.  * </p>
  11.  * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
  12.  * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
  13.  * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
  14.  */
  15. @FunctionalInterface
  16. public interface TaskSupplier
  17. {

  18.     /**
  19.      * Returns a task for the given GTU.
  20.      * @param gtu LaneBasedGtu; gtu
  21.      * @return Task; task for given GTU
  22.      */
  23.     Task getTask(LaneBasedGtu gtu);

  24.     /**
  25.      * Class that supplies a constant task.
  26.      */
  27.     class Constant implements TaskSupplier
  28.     {
  29.         /** Id. */
  30.         private final String id;

  31.         /** Task demand. */
  32.         private final double taskDemand;

  33.         /**
  34.          * Constructor.
  35.          * @param id String; id
  36.          * @param taskDemand double; task demand
  37.          */
  38.         public Constant(final String id, final double taskDemand)
  39.         {
  40.             this.id = id;
  41.             this.taskDemand = taskDemand;
  42.         }

  43.         /** {@inheritDoc} */
  44.         @Override
  45.         public Task getTask(final LaneBasedGtu gtu)
  46.         {
  47.             return new ConstantTask(this.id, this.taskDemand);
  48.         }
  49.     }

  50. }