1 package org.opentrafficsim.imb.kpi;
2
3 import org.opentrafficsim.kpi.interfaces.GtuDataInterface;
4 import org.opentrafficsim.kpi.interfaces.GtuTypeDataInterface;
5 import org.opentrafficsim.kpi.interfaces.NodeDataInterface;
6 import org.opentrafficsim.kpi.interfaces.RouteDataInterface;
7
8
9
10
11
12
13
14
15
16
17
18 public class GtuData implements GtuDataInterface
19 {
20
21 private final String id;
22
23
24 private final GtuTypeData gtuType;
25
26
27 private final RouteData route;
28
29
30
31
32
33
34 public GtuData(final String id, final GtuTypeData gtuType, final RouteData route)
35 {
36 this.id = id;
37 this.gtuType = gtuType;
38 this.route = route;
39 }
40
41
42 @Override
43 public final String getId()
44 {
45 return this.id;
46 }
47
48
49 @Override
50 public final NodeDataInterface getOriginNodeData()
51 {
52 return this.route.getStartNode();
53 }
54
55
56 @Override
57 public final NodeDataInterface getDestinationNodeData()
58 {
59 return this.route.getEndNode();
60 }
61
62
63 @Override
64 public final GtuTypeDataInterface getGtuTypeData()
65 {
66 return this.gtuType;
67 }
68
69
70 @Override
71 public final RouteDataInterface getRouteData()
72 {
73 return this.route;
74 }
75
76
77 @Override
78 public int hashCode()
79 {
80 final int prime = 31;
81 int result = 1;
82 result = prime * result + ((this.gtuType == null) ? 0 : this.gtuType.hashCode());
83 result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
84 return result;
85 }
86
87
88 @Override
89 public boolean equals(Object obj)
90 {
91 if (this == obj)
92 return true;
93 if (obj == null)
94 return false;
95 if (getClass() != obj.getClass())
96 return false;
97 GtuData other = (GtuData) obj;
98 if (this.gtuType == null)
99 {
100 if (other.gtuType != null)
101 return false;
102 }
103 else if (!this.gtuType.equals(other.gtuType))
104 return false;
105 if (this.id == null)
106 {
107 if (other.id != null)
108 return false;
109 }
110 else if (!this.id.equals(other.id))
111 return false;
112 return true;
113 }
114
115
116 @Override
117 public String toString()
118 {
119 return "GtuData [id=" + this.id + ", gtuType=" + this.gtuType + ", route=" + this.route + "]";
120 }
121
122 }