1 package org.opentrafficsim.road.gtu.lane.perception;
2
3 import java.io.Serializable;
4
5 import org.djunits.value.vdouble.scalar.Length;
6
7 import nl.tudelft.simulation.language.Throw;
8
9
10
11
12
13
14
15
16
17
18
19
20 public class InfrastructureLaneChangeInfo implements Comparable<InfrastructureLaneChangeInfo>, Serializable
21 {
22
23
24 private static final long serialVersionUID = 20160811L;
25
26
27 private final int requiredNumberOfLaneChanges;
28
29
30 private final Length remainingDistance;
31
32
33
34
35
36
37
38
39 public InfrastructureLaneChangeInfo(final int requiredNumberOfLaneChanges, final Length remainingDistance)
40 {
41 Throw.when(requiredNumberOfLaneChanges < 0, IllegalArgumentException.class,
42 "Required number of lane changes may not be negative.");
43 Throw.whenNull(remainingDistance, "Remaining distance may not be null.");
44 Throw.when(remainingDistance.si < 0, IllegalArgumentException.class, "Remaining distance may not be negative.");
45 this.requiredNumberOfLaneChanges = requiredNumberOfLaneChanges;
46 this.remainingDistance = remainingDistance;
47 }
48
49
50
51
52 public final int getRequiredNumberOfLaneChanges()
53 {
54 return this.requiredNumberOfLaneChanges;
55 }
56
57
58
59
60 public final Length getRemainingDistance()
61 {
62 return this.remainingDistance;
63 }
64
65
66 @SuppressWarnings("checkstyle:designforextension")
67 @Override
68 public String toString()
69 {
70 return "InfrastructureLaneChangeInfo [requiredNumberOfLaneChanges=" + this.requiredNumberOfLaneChanges
71 + ", remainingDistance=" + this.remainingDistance + "]";
72 }
73
74
75 @Override
76 public final int compareTo(final InfrastructureLaneChangeInfo infrastructureLaneChangeInfo)
77 {
78 return this.remainingDistance.compareTo(infrastructureLaneChangeInfo.getRemainingDistance());
79 }
80
81 }