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-2019 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 String; name of the node
28       * @param position CartesianPoint; 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 String getId()
55      {
56          return this.nodeName;
57      }
58  
59      /** {@inheritDoc} */
60      @Override
61      public int hashCode()
62      {
63          final int prime = 31;
64          int result = 1;
65          result = prime * result + ((this.nodeName == null) ? 0 : this.nodeName.hashCode());
66          return result;
67      }
68  
69      /** {@inheritDoc} */
70      @Override
71      public boolean equals(Object obj)
72      {
73          if (this == obj)
74              return true;
75          if (obj == null)
76              return false;
77          if (getClass() != obj.getClass())
78              return false;
79          NodeData other = (NodeData) obj;
80          if (this.nodeName == null)
81          {
82              if (other.nodeName != null)
83                  return false;
84          }
85          else if (!this.nodeName.equals(other.nodeName))
86              return false;
87          return true;
88      }
89  
90      /** {@inheritDoc} */
91      @Override
92      public String toString()
93      {
94          return "NodeData [nodeName=" + this.nodeName + ", position=" + this.position + "]";
95      }
96  
97  }