View Javadoc
1   package org.opentrafficsim.sim0mq.kpi;
2   
3   import org.opentrafficsim.kpi.interfaces.GtuData;
4   
5   /**
6    * <p>
7    * Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
8    * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
9    * </p>
10   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
11   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
12   * @author <a href="https://dittlab.tudelft.nl">Wouter Schakel</a>
13   */
14  public class GtuDataSim0 implements GtuData
15  {
16      /** id. */
17      private final String id;
18  
19      /** gtu type. */
20      private final String gtuType;
21  
22      /** route. */
23      private final RouteData route;
24  
25      /**
26       * @param id String; the id
27       * @param gtuType GtuTypeData; the gtu type
28       * @param route RouteData; the route
29       */
30      public GtuDataSim0(final String id, final String gtuType, final RouteData route)
31      {
32          this.id = id;
33          this.gtuType = gtuType;
34          this.route = route;
35      }
36  
37      /** {@inheritDoc} */
38      @Override
39      public final String getId()
40      {
41          return this.id;
42      }
43  
44      /** {@inheritDoc} */
45      @Override
46      public final String getOriginId()
47      {
48          return this.route.getStartNode();
49      }
50  
51      /** {@inheritDoc} */
52      @Override
53      public final String getDestinationId()
54      {
55          return this.route.getEndNode();
56      }
57  
58      /** {@inheritDoc} */
59      @Override
60      public final String getGtuId()
61      {
62          return this.gtuType;
63      }
64  
65      /** {@inheritDoc} */
66      @Override
67      public final String getRouteId()
68      {
69          return this.route.getId();
70      }
71  
72      /** {@inheritDoc} */
73      @Override
74      public int hashCode()
75      {
76          final int prime = 31;
77          int result = 1;
78          result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
79          return result;
80      }
81  
82      /** {@inheritDoc} */
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     /** {@inheritDoc} */
104     @Override
105     public String toString()
106     {
107         return "GtuData [id=" + this.id + ", gtuType=" + this.gtuType + ", route=" + this.route + "]";
108     }
109 
110 }