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