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