View Javadoc
1   package org.opentrafficsim.sim0mq.kpi;
2   
3   import org.djunits.value.vdouble.scalar.Length;
4   import org.opentrafficsim.kpi.interfaces.LaneData;
5   
6   /**
7    * <p>
8    * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
9    * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
10   * </p>
11   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
12   * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
13   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
14   */
15  public class LaneDataSim0 implements LaneData<LaneDataSim0>
16  {
17      /** Corresponding Link. */
18      private LinkDataSim0 linkData;
19  
20      /** Wrapped lane. */
21      private final String laneName;
22  
23      /** the link length. */
24      final Length length;
25  
26      /**
27       * @param linkData data about the link
28       * @param laneName name of the lane
29       * @param length length of the lane
30       */
31      public LaneDataSim0(final LinkDataSim0 linkData, final String laneName, final Length length)
32      {
33          this.linkData = linkData;
34          this.laneName = laneName;
35          this.length = length;
36          this.linkData.addLaneData(this);
37      }
38  
39      @Override
40      public final Length getLength()
41      {
42          return this.length;
43      }
44  
45      @Override
46      public final LinkDataSim0 getLinkData()
47      {
48          return this.linkData;
49      }
50  
51      /**
52       * @return laneName
53       */
54      public final String getLaneName()
55      {
56          return this.laneName;
57      }
58  
59      @Override
60      public String getId()
61      {
62          return this.laneName;
63      }
64  
65      /**
66       * @param linkData set linkData
67       */
68      public final void setLinkData(final LinkDataSim0 linkData)
69      {
70          this.linkData = linkData;
71      }
72  
73      @Override
74      public int hashCode()
75      {
76          final int prime = 31;
77          int result = 1;
78          result = prime * result + ((this.laneName == null) ? 0 : this.laneName.hashCode());
79          return result;
80      }
81  
82      @Override
83      public boolean equals(final 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          LaneDataSim0 other = (LaneDataSim0) 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     @Override
103     public String toString()
104     {
105         return "LaneData [linkData=" + this.linkData + ", laneName=" + this.laneName + ", length=" + this.length + "]";
106     }
107 
108 }