View Javadoc
1   package org.opentrafficsim.sim0mq.kpi;
2   
3   import org.djunits.value.vdouble.scalar.Length;
4   import org.opentrafficsim.kpi.interfaces.LaneDataInterface;
5   import org.opentrafficsim.kpi.interfaces.LinkDataInterface;
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 LaneData implements LaneDataInterface
18  {
19      /** Corresponding Link. */
20      private LinkData linkData;
21      
22      /** Wrapped lane. */
23      private final String laneName;
24      
25      /** the link length. */
26      final Length length;
27  
28      /**
29       * @param linkData data about the link
30       * @param laneName name of the lane
31       * @param length length of the lane
32       */
33      public LaneData(final LinkData linkData, final String laneName, final Length length)
34      {
35          this.linkData = linkData;
36          this.laneName = laneName;
37          this.length = length;
38          this.linkData.addLaneData(this);
39      }
40  
41      /** {@inheritDoc} */
42      @Override
43      public final Length getLength()
44      {
45          return this.length;
46      }
47  
48      /** {@inheritDoc} */
49      @Override
50      public final LinkDataInterface getLinkData()
51      {
52          return this.linkData;
53      }
54  
55      /**
56       * @return laneName
57       */
58      public final String getLaneName()
59      {
60          return this.laneName;
61      }
62  
63      /**
64       * @param linkData set linkData
65       */
66      public final void setLinkData(LinkData linkData)
67      {
68          this.linkData = linkData;
69      }
70  
71      /** {@inheritDoc} */
72      @Override
73      public int hashCode()
74      {
75          final int prime = 31;
76          int result = 1;
77          result = prime * result + ((this.laneName == null) ? 0 : this.laneName.hashCode());
78          return result;
79      }
80  
81      /** {@inheritDoc} */
82      @Override
83      public boolean equals(Object obj)
84      {
85          if (this == obj)
86              return true;
87          if (obj == null)
88              return false;
89          if (getClass() != obj.getClass())
90              return false;
91          LaneData other = (LaneData) obj;
92          if (this.laneName == null)
93          {
94              if (other.laneName != null)
95                  return false;
96          }
97          else if (!this.laneName.equals(other.laneName))
98              return false;
99          return true;
100     }
101 
102     /** {@inheritDoc} */
103     @Override
104     public String toString()
105     {
106         return "LaneData [linkData=" + this.linkData + ", laneName=" + this.laneName + ", length=" + this.length + "]";
107     }
108     
109 }