3
3
import java .time .Duration ;
4
4
import java .util .List ;
5
5
import java .util .Objects ;
6
+ import java .util .Optional ;
6
7
import javax .annotation .Nullable ;
7
8
import org .opentripplanner .framework .geometry .WgsCoordinate ;
8
9
import org .opentripplanner .transit .model .framework .FeedScopedId ;
@@ -19,24 +20,27 @@ public class VisitViaLocation extends AbstractViaLocation {
19
20
20
21
private static final Duration MINIMUM_WAIT_TIME_MAX_LIMIT = Duration .ofHours (24 );
21
22
23
+ @ Nullable
22
24
private final Duration minimumWaitTime ;
23
- private final List <WgsCoordinate > coordinates ;
25
+
26
+ @ Nullable
27
+ private final WgsCoordinate coordinate ;
24
28
25
29
public VisitViaLocation (
26
30
@ Nullable String label ,
27
31
@ Nullable Duration minimumWaitTime ,
28
32
List <FeedScopedId > stopLocationIds ,
29
- List < WgsCoordinate > coordinates
33
+ @ Nullable WgsCoordinate coordinate
30
34
) {
31
35
super (label , stopLocationIds );
32
36
this .minimumWaitTime = DurationUtils .requireNonNegative (
33
37
minimumWaitTime == null ? Duration .ZERO : minimumWaitTime ,
34
38
MINIMUM_WAIT_TIME_MAX_LIMIT ,
35
39
"minimumWaitTime"
36
40
);
37
- this .coordinates = List . copyOf ( coordinates ) ;
41
+ this .coordinate = coordinate ;
38
42
39
- if (stopLocationIds ().isEmpty () && coordinates ().isEmpty ()) {
43
+ if (stopLocationIds ().isEmpty () && coordinate ().isEmpty ()) {
40
44
throw new IllegalArgumentException (
41
45
"A via location must have at least one stop location or a coordinate." +
42
46
(label == null ? "" : " Label: " + label )
@@ -60,8 +64,8 @@ public boolean isPassThroughLocation() {
60
64
}
61
65
62
66
@ Override
63
- public List <WgsCoordinate > coordinates () {
64
- return coordinates ;
67
+ public Optional <WgsCoordinate > coordinate () {
68
+ return Optional . ofNullable ( coordinate ) ;
65
69
}
66
70
67
71
@ Override
@@ -70,7 +74,7 @@ public String toString() {
70
74
.addObj ("label" , label ())
71
75
.addDuration ("minimumWaitTime" , minimumWaitTime , Duration .ZERO )
72
76
.addCol ("stopLocationIds" , stopLocationIds ())
73
- .addObj ("coordinates " , coordinates )
77
+ .addObj ("coordinate " , coordinate )
74
78
.toString ();
75
79
}
76
80
@@ -88,12 +92,12 @@ public boolean equals(Object o) {
88
92
VisitViaLocation that = (VisitViaLocation ) o ;
89
93
return (
90
94
Objects .equals (minimumWaitTime , that .minimumWaitTime ) &&
91
- Objects .equals (coordinates , that .coordinates )
95
+ Objects .equals (coordinate , that .coordinate )
92
96
);
93
97
}
94
98
95
99
@ Override
96
100
public int hashCode () {
97
- return Objects .hash (super .hashCode (), minimumWaitTime , coordinates );
101
+ return Objects .hash (super .hashCode (), minimumWaitTime , coordinate );
98
102
}
99
103
}
0 commit comments