View Javadoc
1   package org.opentrafficsim.imb.kpi;
2   
3   import org.opentrafficsim.kpi.interfaces.RouteDataInterface;
4   
5   /**
6    * <p>
7    * Copyright (c) 2013-2016 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
28       * @param startNode
29       * @param endNode
30       */
31      public RouteData(String routeName, NodeData startNode, NodeData endNode)
32      {
33          super();
34          this.routeName = routeName;
35          this.startNode = startNode;
36          this.endNode = endNode;
37      }
38  
39      /**
40       * @return routeName
41       */
42      public final String getRouteName()
43      {
44          return this.routeName;
45      }
46  
47      /**
48       * @return startNode
49       */
50      public final NodeData getStartNode()
51      {
52          return this.startNode;
53      }
54  
55      /**
56       * @return endNode
57       */
58      public final NodeData getEndNode()
59      {
60          return this.endNode;
61      }
62  
63      /** {@inheritDoc} */
64      @Override
65      public int hashCode()
66      {
67          final int prime = 31;
68          int result = 1;
69          result = prime * result + ((this.endNode == null) ? 0 : this.endNode.hashCode());
70          result = prime * result + ((this.routeName == null) ? 0 : this.routeName.hashCode());
71          result = prime * result + ((this.startNode == null) ? 0 : this.startNode.hashCode());
72          return result;
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      public boolean equals(Object obj)
78      {
79          if (this == obj)
80              return true;
81          if (obj == null)
82              return false;
83          if (getClass() != obj.getClass())
84              return false;
85          RouteData other = (RouteData) obj;
86          if (this.endNode == null)
87          {
88              if (other.endNode != null)
89                  return false;
90          }
91          else if (!this.endNode.equals(other.endNode))
92              return false;
93          if (this.routeName == null)
94          {
95              if (other.routeName != null)
96                  return false;
97          }
98          else if (!this.routeName.equals(other.routeName))
99              return false;
100         if (this.startNode == null)
101         {
102             if (other.startNode != null)
103                 return false;
104         }
105         else if (!this.startNode.equals(other.startNode))
106             return false;
107         return true;
108     }
109 
110     /** {@inheritDoc} */
111     @Override
112     public String toString()
113     {
114         return "RouteData [routeName=" + this.routeName + ", startNode=" + this.startNode + ", endNode=" + this.endNode + "]";
115     }
116 
117 }