1 package org.opentrafficsim.road.gtu.lane.perception.object;
2
3 import java.util.Objects;
4
5 import org.djunits.value.vdouble.scalar.Length;
6 import org.opentrafficsim.road.network.lane.Lane;
7
8
9
10
11
12
13
14
15
16
17
18 public class PerceivedLaneBasedObjectBase extends PerceivedObjectBase implements PerceivedLaneBasedObject
19 {
20
21
22 private final Lane lane;
23
24
25
26
27
28
29
30
31
32 public PerceivedLaneBasedObjectBase(final String id, final ObjectType objectType, final Length length,
33 final Kinematics kinematics, final Lane lane)
34 {
35 super(id, objectType, length, kinematics);
36 this.lane = lane;
37 }
38
39
40
41
42
43 @Override
44 public Lane getLane()
45 {
46 return this.lane;
47 }
48
49
50 @Override
51 public int hashCode()
52 {
53 final int prime = 31;
54 int result = super.hashCode();
55 result = prime * result + Objects.hash(this.lane);
56 return result;
57 }
58
59
60 @Override
61 public boolean equals(final Object obj)
62 {
63 if (this == obj)
64 {
65 return true;
66 }
67 if (!super.equals(obj))
68 {
69 return false;
70 }
71 if (getClass() != obj.getClass())
72 {
73 return false;
74 }
75 PerceivedLaneBasedObjectBase other = (PerceivedLaneBasedObjectBase) obj;
76 return Objects.equals(this.lane, other.lane);
77 }
78
79
80 @Override
81 public String toString()
82 {
83 return "PerceivedLaneBasedObject [id=" + getId() + ", type=" + getObjectType() + "]";
84 }
85
86 }