View Javadoc
1   package org.opentrafficsim.sim0mq.kpi;
2   
3   import org.djunits.value.vdouble.scalar.Speed;
4   import org.opentrafficsim.kpi.interfaces.GtuData;
5   
6   /**
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://github.com/peter-knoppers">Peter Knoppers</a>
13   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
14   */
15  public class GtuDataSim0 implements GtuData
16  {
17      /** id. */
18      private final String id;
19  
20      /** gtu type. */
21      private final String gtuType;
22  
23      /** route. */
24      private final RouteData route;
25  
26      /**
27       * @param id the id
28       * @param gtuType the gtu type
29       * @param route the route
30       */
31      public GtuDataSim0(final String id, final String gtuType, final RouteData route)
32      {
33          this.id = id;
34          this.gtuType = gtuType;
35          this.route = route;
36      }
37  
38      @Override
39      public final String getId()
40      {
41          return this.id;
42      }
43  
44      @Override
45      public final String getOriginId()
46      {
47          return this.route.getStartNode();
48      }
49  
50      @Override
51      public final String getDestinationId()
52      {
53          return this.route.getEndNode();
54      }
55  
56      @Override
57      public final String getGtuTypeId()
58      {
59          return this.gtuType;
60      }
61  
62      @Override
63      public final String getRouteId()
64      {
65          return this.route.getId();
66      }
67  
68      @Override
69      public Speed getReferenceSpeed()
70      {
71          return null; // WS 30-09-2023 this project seems broken and I don't know what to return here; there is no network
72      }
73  
74      @Override
75      public int hashCode()
76      {
77          final int prime = 31;
78          int result = 1;
79          result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
80          return result;
81      }
82  
83      @Override
84      public boolean equals(final Object obj)
85      {
86          if (this == obj)
87              return true;
88          if (obj == null)
89              return false;
90          if (getClass() != obj.getClass())
91              return false;
92          GtuDataSim0 other = (GtuDataSim0) obj;
93          if (this.id == null)
94          {
95              if (other.id != null)
96                  return false;
97          }
98          else if (!this.id.equals(other.id))
99              return false;
100         return true;
101     }
102 
103     @Override
104     public String toString()
105     {
106         return "GtuData [id=" + this.id + ", gtuType=" + this.gtuType + ", route=" + this.route + "]";
107     }
108 
109 }