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.LinkData;
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 public class LinkDataRoad implements LinkData<LaneDataRoad>
22 {
23
24
25 private final CrossSectionLink link;
26
27
28
29
30 public LinkDataRoad(final CrossSectionLink link)
31 {
32 this.link = link;
33 }
34
35
36
37
38 public final CrossSectionLink getLink()
39 {
40 return this.link;
41 }
42
43
44 @Override
45 public final List<LaneDataRoad> getLaneDatas()
46 {
47 List<LaneDataRoad> lanes = new ArrayList<>();
48 for (Lane lane : this.link.getLanes())
49 {
50 lanes.add(new LaneDataRoad(lane));
51 }
52 return lanes;
53 }
54
55
56 @Override
57 public final Length getLength()
58 {
59 return this.link.getLength();
60 }
61
62
63 @Override
64 public final String getId()
65 {
66 return this.link.getId();
67 }
68
69
70 @Override
71 public final int hashCode()
72 {
73 final int prime = 31;
74 int result = 1;
75 result = prime * result + ((this.link == null) ? 0 : this.link.hashCode());
76 return result;
77 }
78
79
80 @Override
81 public final boolean equals(final Object obj)
82 {
83 if (this == obj)
84 {
85 return true;
86 }
87 if (obj == null)
88 {
89 return false;
90 }
91 if (getClass() != obj.getClass())
92 {
93 return false;
94 }
95 LinkDataRoad other = (LinkDataRoad) obj;
96 if (this.link == null)
97 {
98 if (other.link != null)
99 {
100 return false;
101 }
102 }
103 else if (!this.link.equals(other.link))
104 {
105 return false;
106 }
107 return true;
108 }
109
110
111 @Override
112 public final String toString()
113 {
114 return "LinkData [link=" + this.link + "]";
115 }
116
117 }