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