Skip to content

Commit 505fefd

Browse files
Clean up after merge
1 parent ea47a56 commit 505fefd

File tree

3 files changed

+31
-76
lines changed

3 files changed

+31
-76
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@
7272
<version>2.1.1</version>
7373
<scope>compile</scope>
7474
</dependency>
75+
<dependency>
76+
<groupId>com.google.guava</groupId>
77+
<artifactId>guava</artifactId>
78+
<version>33.0.0-jre</version>
79+
</dependency>
7580

7681
<!-- Test -->
7782
<dependency>
Lines changed: 17 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package org.opentripplanner.client.parameters;
22

3+
import com.google.common.base.MoreObjects;
4+
import jakarta.annotation.Nullable;
35
import java.time.Duration;
46
import java.time.LocalDateTime;
57
import java.util.Objects;
68
import java.util.Optional;
79
import java.util.Set;
8-
9-
import jakarta.annotation.Nullable;
1010
import org.opentripplanner.client.model.PlaceParameter;
1111
import org.opentripplanner.client.model.RequestMode;
1212
import 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
}

src/test/java/org/opentripplanner/IntegrationTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,19 @@ public void planPlaceToPlaceWithSearchWindow() throws IOException {
9898
.withSearchWindow(Duration.ofDays(1))
9999
.build());
100100

101-
LOG.info("Received {} itineraries", result.itineraries().size());
102-
assertEquals(1, result.itineraries().size());
101+
LOG.info("Received {} itineraries", result.itineraries().size());
102+
assertEquals(1, result.itineraries().size());
103103

104-
assertNotNull(result.itineraries().get(0).legs().get(0).startTime());
104+
assertNotNull(result.itineraries().get(0).legs().get(0).startTime());
105105

106-
var leg = result.itineraries().get(0).legs().get(0);
106+
var leg = result.itineraries().get(0).legs().get(0);
107107

108-
var transitLeg = result.transitItineraries().get(0).transitLegs().get(0);
109-
assertFalse(transitLeg.from().stop().isEmpty());
110-
assertFalse(transitLeg.to().stop().isEmpty());
111-
assertNotNull(transitLeg.from().stop().get().id());
108+
var transitLeg = result.transitItineraries().get(0).transitLegs().get(0);
109+
assertFalse(transitLeg.from().stop().isEmpty());
110+
assertFalse(transitLeg.to().stop().isEmpty());
111+
assertNotNull(transitLeg.from().stop().get().id());
112112

113-
assertEquals(List.of(), leg.fareProducts());
113+
assertEquals(List.of(), leg.fareProducts());
114114
}
115115

116116
@Test

0 commit comments

Comments
 (0)