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       * Constructor.
25       * @param lane wrapped lane
26       */
27      public LaneDataRoad(final Lane lane)
28      {
29          this.lane = lane;
30      }
31  
32      /**
33       * Returns the lane.
34       * @return lane.
35       */
36      public final Lane getLane()
37      {
38          return this.lane;
39      }
40  
41      @Override
42      public final Length getLength()
43      {
44          return this.lane.getLength();
45      }
46  
47      @Override
48      public final LinkDataRoad getLinkData()
49      {
50          return new LinkDataRoad(this.lane.getLink());
51      }
52  
53      @Override
54      public final String getId()
55      {
56          return this.lane.getId();
57      }
58  
59      @Override
60      public final int hashCode()
61      {
62          final int prime = 31;
63          int result = 1;
64          result = prime * result + ((this.lane == null) ? 0 : this.lane.hashCode());
65          return result;
66      }
67  
68      @Override
69      public final boolean equals(final Object obj)
70      {
71          if (this == obj)
72          {
73              return true;
74          }
75          if (obj == null)
76          {
77              return false;
78          }
79          if (getClass() != obj.getClass())
80          {
81              return false;
82          }
83          LaneDataRoad other = (LaneDataRoad) obj;
84          if (this.lane == null)
85          {
86              if (other.lane != null)
87              {
88                  return false;
89              }
90          }
91          else if (!this.lane.equals(other.lane))
92          {
93              return false;
94          }
95          return true;
96      }
97  
98      @Override
99      public final String toString()
100     {
101         return "LaneData [lane=" + this.lane + "]";
102     }
103 
104 }