View Javadoc
1   package org.opentrafficsim.sim0mq.kpi;
2   
3   import org.opentrafficsim.kpi.interfaces.GtuDataInterface;
4   import org.opentrafficsim.kpi.interfaces.GtuTypeDataInterface;
5   import org.opentrafficsim.kpi.interfaces.NodeDataInterface;
6   import org.opentrafficsim.kpi.interfaces.RouteDataInterface;
7   
8   /**
9    * <p>
10   * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
11   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
12   * <p>
13   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 13 okt. 2016 <br>
14   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
15   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
16   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
17   */
18  public class GtuData implements GtuDataInterface
19  {
20      /** id. */
21      private final String id;
22  
23      /** gtu type. */
24      private final GtuTypeData gtuType;
25      
26      /** route. */
27      private final RouteData route;
28     
29      /**
30       * @param id the id
31       * @param gtuType the gtu type
32       * @param route the route
33       */
34      public GtuData(final String id, final GtuTypeData gtuType, final RouteData route)
35      {
36          this.id = id;
37          this.gtuType = gtuType;
38          this.route = route;
39      }
40  
41      /** {@inheritDoc} */
42      @Override
43      public final String getId()
44      {
45          return this.id;
46      }
47  
48      /** {@inheritDoc} */
49      @Override
50      public final NodeDataInterface getOriginNodeData()
51      {
52          return this.route.getStartNode();
53      }
54  
55      /** {@inheritDoc} */
56      @Override
57      public final NodeDataInterface getDestinationNodeData()
58      {
59          return this.route.getEndNode();
60      }
61  
62      /** {@inheritDoc} */
63      @Override
64      public final GtuTypeDataInterface getGtuTypeData()
65      {
66          return this.gtuType;
67      }
68  
69      /** {@inheritDoc} */
70      @Override
71      public final RouteDataInterface getRouteData()
72      {
73          return this.route;
74      }
75  
76      /** {@inheritDoc} */
77      @Override
78      public int hashCode()
79      {
80          final int prime = 31;
81          int result = 1;
82          result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
83          return result;
84      }
85  
86      /** {@inheritDoc} */
87      @Override
88      public boolean equals(Object obj)
89      {
90          if (this == obj)
91              return true;
92          if (obj == null)
93              return false;
94          if (getClass() != obj.getClass())
95              return false;
96          GtuData other = (GtuData) obj;
97          if (this.id == null)
98          {
99              if (other.id != null)
100                 return false;
101         }
102         else if (!this.id.equals(other.id))
103             return false;
104         return true;
105     }
106 
107     /** {@inheritDoc} */
108     @Override
109     public String toString()
110     {
111         return "GtuData [id=" + this.id + ", gtuType=" + this.gtuType + ", route=" + this.route + "]";
112     }
113     
114 }