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.LaneDataInterface;
8 import org.opentrafficsim.kpi.interfaces.LinkDataInterface;
9 import org.opentrafficsim.road.network.lane.CrossSectionLink;
10 import org.opentrafficsim.road.network.lane.Lane;
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<LaneDataInterface> getLaneDatas()
47 {
48 List<LaneDataInterface> 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 int hashCode()
66 {
67 final int prime = 31;
68 int result = 1;
69 result = prime * result + ((this.link == null) ? 0 : this.link.hashCode());
70 return result;
71 }
72
73
74 @Override
75 public final boolean equals(final Object obj)
76 {
77 if (this == obj)
78 {
79 return true;
80 }
81 if (obj == null)
82 {
83 return false;
84 }
85 if (getClass() != obj.getClass())
86 {
87 return false;
88 }
89 LinkData other = (LinkData) obj;
90 if (this.link == null)
91 {
92 if (other.link != null)
93 {
94 return false;
95 }
96 }
97 else if (!this.link.equals(other.link))
98 {
99 return false;
100 }
101 return true;
102 }
103
104
105 @Override
106 public final String toString()
107 {
108 return "LinkData [link=" + this.link + "]";
109 }
110
111 }