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   import org.opentrafficsim.kpi.interfaces.LinkData;
6   
7   /**
8    * <p>
9    * Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
10   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
11   * </p>
12   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
13   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
14   * @author <a href="https://dittlab.tudelft.nl">Wouter Schakel</a>
15   */
16  public class LaneDataSim0 implements LaneData
17  {
18      /** Corresponding Link. */
19      private LinkDataSim0 linkData;
20  
21      /** Wrapped lane. */
22      private final String laneName;
23  
24      /** the link length. */
25      final Length length;
26  
27      /**
28       * @param linkData LinkData; data about the link
29       * @param laneName String; name of the lane
30       * @param length Length; length of the lane
31       */
32      public LaneDataSim0(final LinkDataSim0 linkData, final String laneName, final Length length)
33      {
34          this.linkData = linkData;
35          this.laneName = laneName;
36          this.length = length;
37          this.linkData.addLaneData(this);
38      }
39  
40      /** {@inheritDoc} */
41      @Override
42      public final Length getLength()
43      {
44          return this.length;
45      }
46  
47      /** {@inheritDoc} */
48      @Override
49      public final LinkData getLinkData()
50      {
51          return this.linkData;
52      }
53  
54      /**
55       * @return laneName
56       */
57      public final String getLaneName()
58      {
59          return this.laneName;
60      }
61  
62      /** {@inheritDoc} */
63      @Override
64      public String getId()
65      {
66          return this.laneName;
67      }
68  
69      /**
70       * @param linkData LinkData; set linkData
71       */
72      public final void setLinkData(LinkDataSim0 linkData)
73      {
74          this.linkData = linkData;
75      }
76  
77      /** {@inheritDoc} */
78      @Override
79      public int hashCode()
80      {
81          final int prime = 31;
82          int result = 1;
83          result = prime * result + ((this.laneName == null) ? 0 : this.laneName.hashCode());
84          return result;
85      }
86  
87      /** {@inheritDoc} */
88      @Override
89      public boolean equals(Object obj)
90      {
91          if (this == obj)
92              return true;
93          if (obj == null)
94              return false;
95          if (getClass() != obj.getClass())
96              return false;
97          LaneDataSim0 other = (LaneDataSim0) obj;
98          if (this.laneName == null)
99          {
100             if (other.laneName != null)
101                 return false;
102         }
103         else if (!this.laneName.equals(other.laneName))
104             return false;
105         return true;
106     }
107 
108     /** {@inheritDoc} */
109     @Override
110     public String toString()
111     {
112         return "LaneData [linkData=" + this.linkData + ", laneName=" + this.laneName + ", length=" + this.length + "]";
113     }
114 
115 }