1   package org.opentrafficsim.kpi.sampling;
2   
3   import java.io.Serializable;
4   
5   import org.djunits.value.vdouble.scalar.Length;
6   import org.djutils.exceptions.Throw;
7   import org.opentrafficsim.kpi.interfaces.LaneDataInterface;
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  public class KpiDirectedLanePosition implements Serializable
21  {
22      
23      private static final long serialVersionUID = 20151111L;
24  
25      
26      private final LaneDataInterface lane;
27  
28      
29      private final Length position;
30  
31      
32      private final KpiGtuDirectionality gtuDirection;
33  
34      
35  
36  
37  
38  
39  
40  
41      public KpiDirectedLanePosition(final LaneDataInterface lane, final Length position, final KpiGtuDirectionality gtuDirection)
42      {
43          Throw.whenNull(lane, "lane is null");
44          Throw.whenNull(position, "position is null");
45          Throw.whenNull(gtuDirection, "gtuDirection is null");
46          this.lane = lane;
47          this.position = position;
48          this.gtuDirection = gtuDirection;
49      }
50  
51      
52  
53  
54  
55      public final LaneDataInterface getLaneData()
56      {
57          return this.lane;
58      }
59  
60      
61  
62  
63  
64      public final Length getPosition()
65      {
66          return this.position;
67      }
68  
69      
70  
71  
72  
73  
74      public final KpiGtuDirectionality getKpiGtuDirection()
75      {
76          return this.gtuDirection;
77      }
78  
79      
80      @Override
81      public int hashCode()
82      {
83          final int prime = 31;
84          int result = 1;
85          result = prime * result + ((this.gtuDirection == null) ? 0 : this.gtuDirection.hashCode());
86          result = prime * result + ((this.lane == null) ? 0 : this.lane.hashCode());
87          result = prime * result + ((this.position == null) ? 0 : this.position.hashCode());
88          return result;
89      }
90  
91      
92      @Override
93      public boolean equals(final Object obj)
94      {
95          if (this == obj)
96              return true;
97          if (obj == null)
98              return false;
99          if (getClass() != obj.getClass())
100             return false;
101         KpiDirectedLanePositionopentrafficsim/kpi/sampling/KpiDirectedLanePosition.html#KpiDirectedLanePosition">KpiDirectedLanePosition other = (KpiDirectedLanePosition) obj;
102         if (this.gtuDirection != other.gtuDirection)
103             return false;
104         if (this.lane == null)
105         {
106             if (other.lane != null)
107                 return false;
108         }
109         else if (!this.lane.equals(other.lane))
110             return false;
111         if (this.position == null)
112         {
113             if (other.position != null)
114                 return false;
115         }
116         else if (!this.position.equals(other.position))
117             return false;
118         return true;
119     }
120 
121     
122     @Override
123     public String toString()
124     {
125         return "DirectedLanePosition [lane=" + this.lane + ", position=" + this.position + ", gtuDirection=" + this.gtuDirection
126                 + "]";
127     }
128 
129 }