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.kpi.interfaces.LinkDataInterface;
6   import org.opentrafficsim.road.network.lane.Lane;
7   
8   /**
9    * <p>
10   * Copyright (c) 2013-2016 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 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 LinkDataInterface getLinkData()
50      {
51          return new LinkData(this.lane.getParentLink());
52      }
53  
54      /** {@inheritDoc} */
55      @Override
56      public final int hashCode()
57      {
58          final int prime = 31;
59          int result = 1;
60          result = prime * result + ((this.lane == null) ? 0 : this.lane.hashCode());
61          return result;
62      }
63  
64      /** {@inheritDoc} */
65      @Override
66      public final boolean equals(final Object obj)
67      {
68          if (this == obj)
69          {
70              return true;
71          }
72          if (obj == null)
73          {
74              return false;
75          }
76          if (getClass() != obj.getClass())
77          {
78              return false;
79          }
80          LaneData other = (LaneData) obj;
81          if (this.lane == null)
82          {
83              if (other.lane != null)
84              {
85                  return false;
86              }
87          }
88          else if (!this.lane.equals(other.lane))
89          {
90              return false;
91          }
92          return true;
93      }
94  
95      /** {@inheritDoc} */
96      @Override
97      public final String toString()
98      {
99          return "LaneData [lane=" + this.lane + "]";
100     }
101     
102 }