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