View Javadoc
1   package org.opentrafficsim.road.gtu.lane;
2   
3   import org.opentrafficsim.core.gtu.GtuType;
4   
5   /**
6    * Factory for vehicle models.
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  public interface VehicleModelFactory
16  {
17  
18      /** No vehicle model. */
19      VehicleModelFactory NONE = fixed(VehicleModel.NONE);
20  
21      /** Acceleration bounded vehicle model. */
22      VehicleModelFactory MINMAX = fixed(VehicleModel.MINMAX);
23  
24      /**
25       * Factory returning the same instance always.
26       * @param vehicleModel VehicleModel; vehicle model
27       * @return fixed vehicle model
28       */
29      static VehicleModelFactory fixed(final VehicleModel vehicleModel)
30      {
31          return new VehicleModelFactory()
32          {
33              @Override
34              public VehicleModel create(final GtuType gtuType)
35              {
36                  return vehicleModel;
37              }
38          };
39      }
40  
41      /**
42       * Create next vehicle model for given GTU type.
43       * @param gtuType GtuType; GTU type
44       * @return next vehicle model for given GTU type
45       */
46      VehicleModel create(GtuType gtuType);
47  
48  }