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