View Javadoc
1   package org.opentrafficsim.road.network.sampling;
2   
3   import org.opentrafficsim.core.network.Node;
4   import org.opentrafficsim.kpi.interfaces.NodeDataInterface;
5   
6   /**
7    * Node representation in road sampler.
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. */
21      private final Node node;
22  
23      /**
24       * @param node Node; node
25       */
26      public NodeData(final Node node)
27      {
28          this.node = node;
29      }
30  
31      /**
32       * @return node.
33       */
34      public final Node getNode()
35      {
36          return this.node;
37      }
38  
39      /** {@inheritDoc} */
40      @Override
41      public final String getId()
42      {
43          return this.node.getId();
44      }
45  
46      /** {@inheritDoc} */
47      @Override
48      public final int hashCode()
49      {
50          final int prime = 31;
51          int result = 1;
52          result = prime * result + ((this.node == null) ? 0 : this.node.hashCode());
53          return result;
54      }
55  
56      /** {@inheritDoc} */
57      @Override
58      public final boolean equals(final Object obj)
59      {
60          if (this == obj)
61          {
62              return true;
63          }
64          if (obj == null)
65          {
66              return false;
67          }
68          if (getClass() != obj.getClass())
69          {
70              return false;
71          }
72          NodeData other = (NodeData) obj;
73          if (this.node == null)
74          {
75              if (other.node != null)
76              {
77                  return false;
78              }
79          }
80          else if (!this.node.equals(other.node))
81          {
82              return false;
83          }
84          return true;
85      }
86  
87      /** {@inheritDoc} */
88      @Override
89      public final String toString()
90      {
91          return "NodeData [node=" + this.node + "]";
92      }
93  
94  }