1 package org.opentrafficsim.imb.kpi;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.djunits.value.vdouble.scalar.Length;
7 import org.opentrafficsim.kpi.interfaces.LaneDataInterface;
8 import org.opentrafficsim.kpi.interfaces.LinkDataInterface;
9
10
11
12
13
14
15
16
17
18
19
20 public class LinkData implements LinkDataInterface
21 {
22
23
24 private final String linkName;
25
26
27 final NodeData startNode;
28
29
30 final NodeData endNode;
31
32
33 private final List<LaneDataInterface> laneDataList = new ArrayList<>();
34
35
36 private final Length length;
37
38
39
40
41
42
43
44 public LinkData(final String linkName, final NodeData startNode, final NodeData endNode, final Length length)
45 {
46 this.linkName = linkName;
47 this.length = length;
48 this.startNode = startNode;
49 this.endNode = endNode;
50 }
51
52
53
54
55
56 public void addLaneData(final LaneData laneData)
57 {
58 this.laneDataList.add(laneData);
59 }
60
61
62 @Override
63 public final List<LaneDataInterface> getLaneDatas()
64 {
65 return this.laneDataList;
66 }
67
68
69 @Override
70 public final Length getLength()
71 {
72 return this.length;
73 }
74
75
76
77
78 public final NodeData getStartNode()
79 {
80 return this.startNode;
81 }
82
83
84
85
86 public final NodeData getEndNode()
87 {
88 return this.endNode;
89 }
90
91
92
93
94 public final String getLinkName()
95 {
96 return this.linkName;
97 }
98
99
100 @Override
101 public int hashCode()
102 {
103 final int prime = 31;
104 int result = 1;
105 result = prime * result + ((this.endNode == null) ? 0 : this.endNode.hashCode());
106 result = prime * result + ((this.length == null) ? 0 : this.length.hashCode());
107 result = prime * result + ((this.linkName == null) ? 0 : this.linkName.hashCode());
108 result = prime * result + ((this.startNode == null) ? 0 : this.startNode.hashCode());
109 return result;
110 }
111
112
113 @Override
114 public boolean equals(Object obj)
115 {
116 if (this == obj)
117 return true;
118 if (obj == null)
119 return false;
120 if (getClass() != obj.getClass())
121 return false;
122 LinkData other = (LinkData) obj;
123 if (this.endNode == null)
124 {
125 if (other.endNode != null)
126 return false;
127 }
128 else if (!this.endNode.equals(other.endNode))
129 return false;
130 if (this.length == null)
131 {
132 if (other.length != null)
133 return false;
134 }
135 else if (!this.length.equals(other.length))
136 return false;
137 if (this.linkName == null)
138 {
139 if (other.linkName != null)
140 return false;
141 }
142 else if (!this.linkName.equals(other.linkName))
143 return false;
144 if (this.startNode == null)
145 {
146 if (other.startNode != null)
147 return false;
148 }
149 else if (!this.startNode.equals(other.startNode))
150 return false;
151 return true;
152 }
153
154
155 @Override
156 public String toString()
157 {
158 return "LinkData [linkName=" + this.linkName + ", startNode=" + this.startNode + ", endNode=" + this.endNode
159 + ", length=" + this.length + ", laneDataList.size()=" + this.laneDataList.size() + "]";
160 }
161
162 }