View Javadoc
1   package org.opentrafficsim.sim0mq.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 name of the node
28       * @param position  position of the node
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          return result;
60      }
61  
62      /** {@inheritDoc} */
63      @Override
64      public boolean equals(Object obj)
65      {
66          if (this == obj)
67              return true;
68          if (obj == null)
69              return false;
70          if (getClass() != obj.getClass())
71              return false;
72          NodeData other = (NodeData) obj;
73          if (this.nodeName == null)
74          {
75              if (other.nodeName != null)
76                  return false;
77          }
78          else if (!this.nodeName.equals(other.nodeName))
79              return false;
80          return true;
81      }
82  
83      /** {@inheritDoc} */
84      @Override
85      public String toString()
86      {
87          return "NodeData [nodeName=" + this.nodeName + ", position=" + this.position + "]";
88      }
89  
90  }