1 package org.opentrafficsim.road.gtu.generator.characteristics;
2
3 import java.util.function.Supplier;
4
5 import org.djunits.value.vdouble.scalar.Length;
6 import org.djunits.value.vdouble.scalar.Speed;
7 import org.djutils.exceptions.Throw;
8 import org.opentrafficsim.core.gtu.GtuTemplate;
9 import org.opentrafficsim.core.gtu.GtuType;
10 import org.opentrafficsim.core.network.route.Route;
11 import org.opentrafficsim.road.gtu.lane.VehicleModel;
12 import org.opentrafficsim.road.gtu.strategical.LaneBasedStrategicalPlannerFactory;
13
14
15
16
17
18
19
20
21
22
23 public class LaneBasedGtuTemplate extends GtuTemplate implements LaneBasedGtuCharacteristicsGenerator
24 {
25
26 private final LaneBasedStrategicalPlannerFactory<?> strategicalPlannerFactory;
27
28
29 private final Supplier<Route> routeSupplier;
30
31
32
33
34
35
36
37
38
39
40
41 @SuppressWarnings("checkstyle:parameternumber")
42 public LaneBasedGtuTemplate(final GtuType gtuType, final Supplier<Length> lengthSupplier,
43 final Supplier<Length> widthSupplier, final Supplier<Speed> maximumSpeedSupplier,
44 final LaneBasedStrategicalPlannerFactory<?> strategicalPlannerFactory, final Supplier<Route> routeSupplier)
45 throws NullPointerException
46 {
47 super(gtuType, lengthSupplier, widthSupplier, maximumSpeedSupplier);
48 Throw.whenNull(strategicalPlannerFactory, "strategicalPlannerFactory is null");
49 Throw.whenNull(routeSupplier, "Route Supplier is null");
50 this.strategicalPlannerFactory = strategicalPlannerFactory;
51 this.routeSupplier = routeSupplier;
52 }
53
54
55
56
57
58 @Override
59 public final LaneBasedGtuCharacteristics draw()
60 {
61 return new LaneBasedGtuCharacteristics(super.get(), this.strategicalPlannerFactory, this.routeSupplier.get(), null,
62 null, VehicleModel.MINMAX);
63 }
64
65 @Override
66 @SuppressWarnings("checkstyle:designforextension")
67 public String toString()
68 {
69 return String.format("LaneBasedGtuTemplate [%s, %s]", this.strategicalPlannerFactory, super.toString());
70 }
71
72 }