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://tudelft.nl/staff/p.knoppers-1">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 String; the id
28       * @param gtuType GtuTypeData; the gtu type
29       * @param route RouteData; 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      /** {@inheritDoc} */
39      @Override
40      public final String getId()
41      {
42          return this.id;
43      }
44  
45      /** {@inheritDoc} */
46      @Override
47      public final String getOriginId()
48      {
49          return this.route.getStartNode();
50      }
51  
52      /** {@inheritDoc} */
53      @Override
54      public final String getDestinationId()
55      {
56          return this.route.getEndNode();
57      }
58  
59      /** {@inheritDoc} */
60      @Override
61      public final String getGtuTypeId()
62      {
63          return this.gtuType;
64      }
65  
66      /** {@inheritDoc} */
67      @Override
68      public final String getRouteId()
69      {
70          return this.route.getId();
71      }
72  
73      /** {@inheritDoc} */
74      @Override
75      public Speed getReferenceSpeed()
76      {
77          return null; // WS 30-09-2023 this project seems broken and I don't know what to return here; there is no network
78      }
79      
80      /** {@inheritDoc} */
81      @Override
82      public int hashCode()
83      {
84          final int prime = 31;
85          int result = 1;
86          result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
87          return result;
88      }
89  
90      /** {@inheritDoc} */
91      @Override
92      public boolean equals(final Object obj)
93      {
94          if (this == obj)
95              return true;
96          if (obj == null)
97              return false;
98          if (getClass() != obj.getClass())
99              return false;
100         GtuDataSim0 other = (GtuDataSim0) obj;
101         if (this.id == null)
102         {
103             if (other.id != null)
104                 return false;
105         }
106         else if (!this.id.equals(other.id))
107             return false;
108         return true;
109     }
110 
111     /** {@inheritDoc} */
112     @Override
113     public String toString()
114     {
115         return "GtuData [id=" + this.id + ", gtuType=" + this.gtuType + ", route=" + this.route + "]";
116     }
117 
118 }