1 package org.opentrafficsim.road.network.sampling;
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.LinkDataInterface;
8 import org.opentrafficsim.road.network.lane.CrossSectionLink;
9 import org.opentrafficsim.road.network.lane.Lane;
10
11
12
13
14
15
16
17
18
19
20
21
22 public class LinkData implements LinkDataInterface
23 {
24
25
26 private final CrossSectionLink link;
27
28
29
30
31 public LinkData(final CrossSectionLink link)
32 {
33 this.link = link;
34 }
35
36
37
38
39 public final CrossSectionLink getLink()
40 {
41 return this.link;
42 }
43
44
45 @Override
46 public final List<LaneData> getLaneDatas()
47 {
48 List<LaneData> lanes = new ArrayList<>();
49 for (Lane lane : this.link.getLanes())
50 {
51 lanes.add(new LaneData(lane));
52 }
53 return lanes;
54 }
55
56
57 @Override
58 public final Length getLength()
59 {
60 return this.link.getLength();
61 }
62
63
64 @Override
65 public final String getId()
66 {
67 return this.link.getId();
68 }
69
70
71 @Override
72 public final int hashCode()
73 {
74 final int prime = 31;
75 int result = 1;
76 result = prime * result + ((this.link == null) ? 0 : this.link.hashCode());
77 return result;
78 }
79
80
81 @Override
82 public final 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 LinkData other = (LinkData) obj;
97 if (this.link == null)
98 {
99 if (other.link != null)
100 {
101 return false;
102 }
103 }
104 else if (!this.link.equals(other.link))
105 {
106 return false;
107 }
108 return true;
109 }
110
111
112 @Override
113 public final String toString()
114 {
115 return "LinkData [link=" + this.link + "]";
116 }
117
118 }