View Javadoc
1   package org.opentrafficsim.road.network.sampling;
2   
3   import org.djunits.value.vdouble.scalar.Length;
4   import org.opentrafficsim.kpi.interfaces.LaneData;
5   import org.opentrafficsim.road.network.lane.Lane;
6   
7   /**
8    * Lane representation in road sampler.
9    * <p>
10   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
11   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
12   * </p>
13   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
14   * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
15   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
16   */
17  public class LaneDataRoad implements LaneData<LaneDataRoad>
18  {
19  
20      /** Wrapped lane. */
21      private final Lane lane;
22  
23      /**
24       * @param lane wrapped lane
25       */
26      public LaneDataRoad(final Lane lane)
27      {
28          this.lane = lane;
29      }
30  
31      /**
32       * @return lane.
33       */
34      public final Lane getLane()
35      {
36          return this.lane;
37      }
38  
39      @Override
40      public final Length getLength()
41      {
42          return this.lane.getLength();
43      }
44  
45      @Override
46      public final LinkDataRoad getLinkData()
47      {
48          return new LinkDataRoad(this.lane.getLink());
49      }
50  
51      @Override
52      public final String getId()
53      {
54          return this.lane.getId();
55      }
56  
57      @Override
58      public final int hashCode()
59      {
60          final int prime = 31;
61          int result = 1;
62          result = prime * result + ((this.lane == null) ? 0 : this.lane.hashCode());
63          return result;
64      }
65  
66      @Override
67      public final boolean equals(final Object obj)
68      {
69          if (this == obj)
70          {
71              return true;
72          }
73          if (obj == null)
74          {
75              return false;
76          }
77          if (getClass() != obj.getClass())
78          {
79              return false;
80          }
81          LaneDataRoad other = (LaneDataRoad) obj;
82          if (this.lane == null)
83          {
84              if (other.lane != null)
85              {
86                  return false;
87              }
88          }
89          else if (!this.lane.equals(other.lane))
90          {
91              return false;
92          }
93          return true;
94      }
95  
96      @Override
97      public final String toString()
98      {
99          return "LaneData [lane=" + this.lane + "]";
100     }
101 
102 }