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://tudelft.nl/staff/p.knoppers-1">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 LinkData; data about the link
28       * @param laneName String; name of the lane
29       * @param length 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      /** {@inheritDoc} */
40      @Override
41      public final Length getLength()
42      {
43          return this.length;
44      }
45  
46      /** {@inheritDoc} */
47      @Override
48      public final LinkDataSim0 getLinkData()
49      {
50          return this.linkData;
51      }
52  
53      /**
54       * @return laneName
55       */
56      public final String getLaneName()
57      {
58          return this.laneName;
59      }
60  
61      /** {@inheritDoc} */
62      @Override
63      public String getId()
64      {
65          return this.laneName;
66      }
67  
68      /**
69       * @param linkData LinkData; set linkData
70       */
71      public final void setLinkData(final LinkDataSim0 linkData)
72      {
73          this.linkData = linkData;
74      }
75  
76      /** {@inheritDoc} */
77      @Override
78      public int hashCode()
79      {
80          final int prime = 31;
81          int result = 1;
82          result = prime * result + ((this.laneName == null) ? 0 : this.laneName.hashCode());
83          return result;
84      }
85  
86      /** {@inheritDoc} */
87      @Override
88      public boolean equals(final Object obj)
89      {
90          if (this == obj)
91              return true;
92          if (obj == null)
93              return false;
94          if (getClass() != obj.getClass())
95              return false;
96          LaneDataSim0 other = (LaneDataSim0) obj;
97          if (this.laneName == null)
98          {
99              if (other.laneName != null)
100                 return false;
101         }
102         else if (!this.laneName.equals(other.laneName))
103             return false;
104         return true;
105     }
106 
107     /** {@inheritDoc} */
108     @Override
109     public String toString()
110     {
111         return "LaneData [linkData=" + this.linkData + ", laneName=" + this.laneName + ", length=" + this.length + "]";
112     }
113 
114 }