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