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.djutils.exceptions.Throw;
7
8
9
10
11
12
13
14
15
16
17
18 public class PerceivedObjectBase implements PerceivedObject
19 {
20
21
22 private final String id;
23
24
25 private final ObjectType objectType;
26
27
28 private final Length length;
29
30
31 private final Kinematics kinematics;
32
33
34
35
36
37
38
39
40
41 public PerceivedObjectBase(final String id, final ObjectType objectType, final Length length, final Kinematics kinematics)
42 {
43 this.id = Throw.whenNull(id, "id");
44 this.objectType = Throw.whenNull(objectType, "objectType");
45 this.length = Throw.whenNull(length, "length");
46 this.kinematics = Throw.whenNull(kinematics, "kinematics");
47 }
48
49 @Override
50 public String getId()
51 {
52 return this.id;
53 }
54
55 @Override
56 public ObjectType getObjectType()
57 {
58 return this.objectType;
59 }
60
61 @Override
62 public Length getLength()
63 {
64 return this.length;
65 }
66
67 @Override
68 public Kinematics getKinematics()
69 {
70 return this.kinematics;
71 }
72
73
74 @Override
75 public int hashCode()
76 {
77 return Objects.hash(this.id, this.kinematics, this.length, this.objectType);
78 }
79
80
81 @Override
82 public boolean equals(final Object obj)
83 {
84 if (this == obj)
85 {
86 return true;
87 }
88 if (obj == null)
89 {
90 return false;
91 }
92 if (getClass() != obj.getClass())
93 {
94 return false;
95 }
96 PerceivedObjectBase other = (PerceivedObjectBase) obj;
97 return Objects.equals(this.id, other.id) && Objects.equals(this.kinematics, other.kinematics)
98 && Objects.equals(this.length, other.length) && this.objectType == other.objectType;
99 }
100
101
102 @Override
103 public String toString()
104 {
105 return "PerceivedObjectBase [id=" + this.id + ", objectType=" + this.objectType + "]";
106 }
107
108 }