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.LinkData;
8
9
10
11
12
13
14
15
16
17
18 public class LinkDataSim0 implements LinkData<LaneDataSim0>
19 {
20
21
22 private final String linkName;
23
24
25 final String startNode;
26
27
28 final String endNode;
29
30
31 private final List<LaneDataSim0> laneDataList = new ArrayList<>();
32
33
34 private final Length length;
35
36
37
38
39
40
41
42 public LinkDataSim0(final String linkName, final String startNode, final String endNode, final Length length)
43 {
44 this.linkName = linkName;
45 this.length = length;
46 this.startNode = startNode;
47 this.endNode = endNode;
48 }
49
50
51
52
53
54 public void addLaneData(final LaneDataSim0 laneData)
55 {
56 this.laneDataList.add(laneData);
57 }
58
59 @Override
60 public final List<LaneDataSim0> getLanes()
61 {
62 return this.laneDataList;
63 }
64
65 @Override
66 public final Length getLength()
67 {
68 return this.length;
69 }
70
71
72
73
74 public final String getStartNode()
75 {
76 return this.startNode;
77 }
78
79
80
81
82 public final String getEndNode()
83 {
84 return this.endNode;
85 }
86
87
88
89
90 public final String getLinkName()
91 {
92 return this.linkName;
93 }
94
95 @Override
96 public String getId()
97 {
98 return this.linkName;
99 }
100
101 @Override
102 public int hashCode()
103 {
104 final int prime = 31;
105 int result = 1;
106 result = prime * result + ((this.endNode == null) ? 0 : this.endNode.hashCode());
107 result = prime * result + ((this.length == null) ? 0 : this.length.hashCode());
108 result = prime * result + ((this.linkName == null) ? 0 : this.linkName.hashCode());
109 result = prime * result + ((this.startNode == null) ? 0 : this.startNode.hashCode());
110 return result;
111 }
112
113 @Override
114 public boolean equals(final 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 LinkDataSim0 other = (LinkDataSim0) obj;
123 if (this.linkName == null)
124 {
125 if (other.linkName != null)
126 return false;
127 }
128 else if (!this.linkName.equals(other.linkName))
129 return false;
130 return true;
131 }
132
133 @Override
134 public String toString()
135 {
136 return "LinkData [linkName=" + this.linkName + ", startNode=" + this.startNode + ", endNode=" + this.endNode
137 + ", length=" + this.length + ", laneDataList.size()=" + this.laneDataList.size() + "]";
138 }
139
140 }