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.LaneData;
8
9
10
11
12
13
14
15
16
17
18 public class LanePosition implements Serializable
19 {
20
21 private static final long serialVersionUID = 20151111L;
22
23
24 private final LaneData lane;
25
26
27 private final Length position;
28
29
30
31
32
33
34 public LanePosition(final LaneData lane, final Length position)
35 {
36 Throw.whenNull(lane, "lane is null");
37 Throw.whenNull(position, "position is null");
38 this.lane = lane;
39 this.position = position;
40 }
41
42
43
44
45
46 public final LaneData getLaneData()
47 {
48 return this.lane;
49 }
50
51
52
53
54
55 public final Length getPosition()
56 {
57 return this.position;
58 }
59
60
61 @Override
62 public int hashCode()
63 {
64 final int prime = 31;
65 int result = 1;
66 result = prime * result + ((this.lane == null) ? 0 : this.lane.hashCode());
67 result = prime * result + ((this.position == null) ? 0 : this.position.hashCode());
68 return result;
69 }
70
71
72 @Override
73 @SuppressWarnings("checkstyle:needbraces")
74 public boolean equals(final Object obj)
75 {
76 if (this == obj)
77 return true;
78 if (obj == null)
79 return false;
80 if (getClass() != obj.getClass())
81 return false;
82 LanePosition other = (LanePosition) obj;
83 if (this.lane == null)
84 {
85 if (other.lane != null)
86 return false;
87 }
88 else if (!this.lane.equals(other.lane))
89 return false;
90 if (this.position == null)
91 {
92 if (other.position != null)
93 return false;
94 }
95 else if (!this.position.equals(other.position))
96 return false;
97 return true;
98 }
99
100
101 @Override
102 public String toString()
103 {
104 return "LanePosition [lane=" + this.lane + ", position=" + this.position + "]";
105 }
106
107 }