11package org .opentripplanner .client .parameters ;
22
3+ import com .google .common .base .MoreObjects ;
4+ import jakarta .annotation .Nullable ;
35import java .time .Duration ;
46import java .time .LocalDateTime ;
57import java .util .Objects ;
68import java .util .Optional ;
79import java .util .Set ;
8-
9- import jakarta .annotation .Nullable ;
1010import org .opentripplanner .client .model .PlaceParameter ;
1111import org .opentripplanner .client .model .RequestMode ;
1212import org .opentripplanner .client .validation .CollectionUtils ;
@@ -18,8 +18,7 @@ public final class TripPlanParameters {
1818 private final int numItineraries ;
1919 private final Set <RequestMode > modes ;
2020 private final SearchDirection searchDirection ;
21- @ Nullable
22- private final Duration searchWindow ;
21+ @ Nullable private final Duration searchWindow ;
2322 private final float walkReluctance ;
2423 private final boolean wheelchair ;
2524
@@ -30,17 +29,15 @@ public TripPlanParameters(
3029 int numItineraries ,
3130 Set <RequestMode > modes ,
3231 SearchDirection searchDirection ,
33- Duration searchWindow ,
32+ @ Nullable Duration searchWindow ,
3433 float walkReluctance ,
35- boolean wheelchair
36- ) {
37- CollectionUtils .assertHasValue (modes );
34+ boolean wheelchair ) {
3835
3936 this .fromPlace = Objects .requireNonNull (fromPlace );
4037 this .toPlace = Objects .requireNonNull (toPlace );
4138 this .time = Objects .requireNonNull (time );
4239 this .numItineraries = numItineraries ;
43- this .modes = Objects . requireNonNull ( modes );
40+ this .modes = Set . copyOf ( CollectionUtils . assertHasValue ( modes ) );
4441 this .searchDirection = Objects .requireNonNull (searchDirection );
4542 this .searchWindow = searchWindow ;
4643 this .walkReluctance = walkReluctance ;
@@ -96,65 +93,18 @@ public boolean wheelchair() {
9693 return wheelchair ;
9794 }
9895
99- @ Override
100- public boolean equals (Object obj ) {
101- if (obj == this ) return true ;
102- if (obj == null || obj .getClass () != this .getClass ()) return false ;
103- var that = (TripPlanParameters ) obj ;
104- return Objects .equals (this .fromPlace , that .fromPlace )
105- && Objects .equals (this .toPlace , that .toPlace )
106- && Objects .equals (this .time , that .time )
107- && this .numItineraries == that .numItineraries
108- && Objects .equals (this .modes , that .modes )
109- && Objects .equals (this .searchDirection , that .searchDirection )
110- && Objects .equals (this .searchWindow , that .searchWindow )
111- && Float .floatToIntBits (this .walkReluctance ) == Float .floatToIntBits (that .walkReluctance )
112- && this .wheelchair == that .wheelchair ;
113- }
114-
115- @ Override
116- public int hashCode () {
117- return Objects .hash (
118- fromPlace ,
119- toPlace ,
120- time ,
121- numItineraries ,
122- modes ,
123- searchDirection ,
124- searchWindow ,
125- walkReluctance ,
126- wheelchair );
127- }
128-
12996 @ Override
13097 public String toString () {
131- return "TripPlanParameters["
132- + "fromPlace="
133- + fromPlace
134- + ", "
135- + "toPlace="
136- + toPlace
137- + ", "
138- + "time="
139- + time
140- + ", "
141- + "numItineraries="
142- + numItineraries
143- + ", "
144- + "modes="
145- + modes
146- + ", "
147- + "searchDirection="
148- + searchDirection
149- + ", "
150- + "searchWindow="
151- + searchWindow
152- + ", "
153- + "walkReluctance="
154- + walkReluctance
155- + ", "
156- + "wheelchair="
157- + wheelchair
158- + ']' ;
98+ return MoreObjects .toStringHelper (this )
99+ .add ("fromPlace" , fromPlace )
100+ .add ("toPlace" , toPlace )
101+ .add ("time" , time )
102+ .add ("numItineraries" , numItineraries )
103+ .add ("modes" , modes )
104+ .add ("searchDirection" , searchDirection )
105+ .add ("searchWindow" , searchWindow )
106+ .add ("walkReluctance" , walkReluctance )
107+ .add ("wheelchair" , wheelchair )
108+ .toString ();
159109 }
160110}
0 commit comments