1 package org.opentrafficsim.sim0mq.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 String getId()
102 {
103 return this.linkName;
104 }
105
106
107 @Override
108 public int hashCode()
109 {
110 final int prime = 31;
111 int result = 1;
112 result = prime * result + ((this.endNode == null) ? 0 : this.endNode.hashCode());
113 result = prime * result + ((this.length == null) ? 0 : this.length.hashCode());
114 result = prime * result + ((this.linkName == null) ? 0 : this.linkName.hashCode());
115 result = prime * result + ((this.startNode == null) ? 0 : this.startNode.hashCode());
116 return result;
117 }
118
119
120 @Override
121 public boolean equals(Object obj)
122 {
123 if (this == obj)
124 return true;
125 if (obj == null)
126 return false;
127 if (getClass() != obj.getClass())
128 return false;
129 LinkData other = (LinkData) obj;
130 if (this.linkName == null)
131 {
132 if (other.linkName != null)
133 return false;
134 }
135 else if (!this.linkName.equals(other.linkName))
136 return false;
137 return true;
138 }
139
140
141 @Override
142 public String toString()
143 {
144 return "LinkData [linkName=" + this.linkName + ", startNode=" + this.startNode + ", endNode=" + this.endNode
145 + ", length=" + this.length + ", laneDataList.size()=" + this.laneDataList.size() + "]";
146 }
147
148 }