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