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