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-2018 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      /** {@inheritDoc} */
64      @Override
65      public String getId()
66      {
67          return this.laneName;
68      }
69  
70      /**
71       * @param linkData set linkData
72       */
73      public final void setLinkData(LinkData linkData)
74      {
75          this.linkData = linkData;
76      }
77  
78      /** {@inheritDoc} */
79      @Override
80      public int hashCode()
81      {
82          final int prime = 31;
83          int result = 1;
84          result = prime * result + ((this.laneName == null) ? 0 : this.laneName.hashCode());
85          return result;
86      }
87  
88      /** {@inheritDoc} */
89      @Override
90      public boolean equals(Object obj)
91      {
92          if (this == obj)
93              return true;
94          if (obj == null)
95              return false;
96          if (getClass() != obj.getClass())
97              return false;
98          LaneData other = (LaneData) obj;
99          if (this.laneName == null)
100         {
101             if (other.laneName != null)
102                 return false;
103         }
104         else if (!this.laneName.equals(other.laneName))
105             return false;
106         return true;
107     }
108 
109     /** {@inheritDoc} */
110     @Override
111     public String toString()
112     {
113         return "LaneData [linkData=" + this.linkData + ", laneName=" + this.laneName + ", length=" + this.length + "]";
114     }
115     
116 }