diff --git a/pom.xml b/pom.xml
index 384058d..f84d1a0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,6 +72,11 @@
2.1.1
compile
+
+ com.google.guava
+ guava
+ 33.0.0-jre
+
diff --git a/src/main/java/org/opentripplanner/client/parameters/TripPlanParameters.java b/src/main/java/org/opentripplanner/client/parameters/TripPlanParameters.java
index e6879c9..4ccacb4 100644
--- a/src/main/java/org/opentripplanner/client/parameters/TripPlanParameters.java
+++ b/src/main/java/org/opentripplanner/client/parameters/TripPlanParameters.java
@@ -1,12 +1,12 @@
package org.opentripplanner.client.parameters;
+import com.google.common.base.MoreObjects;
+import jakarta.annotation.Nullable;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
-
-import jakarta.annotation.Nullable;
import org.opentripplanner.client.model.PlaceParameter;
import org.opentripplanner.client.model.RequestMode;
import org.opentripplanner.client.validation.CollectionUtils;
@@ -18,8 +18,7 @@ public final class TripPlanParameters {
private final int numItineraries;
private final Set modes;
private final SearchDirection searchDirection;
- @Nullable
- private final Duration searchWindow;
+ @Nullable private final Duration searchWindow;
private final float walkReluctance;
private final boolean wheelchair;
@@ -30,17 +29,15 @@ public TripPlanParameters(
int numItineraries,
Set modes,
SearchDirection searchDirection,
- Duration searchWindow,
+ @Nullable Duration searchWindow,
float walkReluctance,
- boolean wheelchair
- ) {
- CollectionUtils.assertHasValue(modes);
+ boolean wheelchair) {
this.fromPlace = Objects.requireNonNull(fromPlace);
this.toPlace = Objects.requireNonNull(toPlace);
this.time = Objects.requireNonNull(time);
this.numItineraries = numItineraries;
- this.modes = Objects.requireNonNull(modes);
+ this.modes = Set.copyOf(CollectionUtils.assertHasValue(modes));
this.searchDirection = Objects.requireNonNull(searchDirection);
this.searchWindow = searchWindow;
this.walkReluctance = walkReluctance;
@@ -96,65 +93,18 @@ public boolean wheelchair() {
return wheelchair;
}
- @Override
- public boolean equals(Object obj) {
- if (obj == this) return true;
- if (obj == null || obj.getClass() != this.getClass()) return false;
- var that = (TripPlanParameters) obj;
- return Objects.equals(this.fromPlace, that.fromPlace)
- && Objects.equals(this.toPlace, that.toPlace)
- && Objects.equals(this.time, that.time)
- && this.numItineraries == that.numItineraries
- && Objects.equals(this.modes, that.modes)
- && Objects.equals(this.searchDirection, that.searchDirection)
- && Objects.equals(this.searchWindow, that.searchWindow)
- && Float.floatToIntBits(this.walkReluctance) == Float.floatToIntBits(that.walkReluctance)
- && this.wheelchair == that.wheelchair;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(
- fromPlace,
- toPlace,
- time,
- numItineraries,
- modes,
- searchDirection,
- searchWindow,
- walkReluctance,
- wheelchair);
- }
-
@Override
public String toString() {
- return "TripPlanParameters["
- + "fromPlace="
- + fromPlace
- + ", "
- + "toPlace="
- + toPlace
- + ", "
- + "time="
- + time
- + ", "
- + "numItineraries="
- + numItineraries
- + ", "
- + "modes="
- + modes
- + ", "
- + "searchDirection="
- + searchDirection
- + ", "
- + "searchWindow="
- + searchWindow
- + ", "
- + "walkReluctance="
- + walkReluctance
- + ", "
- + "wheelchair="
- + wheelchair
- + ']';
+ return MoreObjects.toStringHelper(this)
+ .add("fromPlace", fromPlace)
+ .add("toPlace", toPlace)
+ .add("time", time)
+ .add("numItineraries", numItineraries)
+ .add("modes", modes)
+ .add("searchDirection", searchDirection)
+ .add("searchWindow", searchWindow)
+ .add("walkReluctance", walkReluctance)
+ .add("wheelchair", wheelchair)
+ .toString();
}
}
diff --git a/src/test/java/org/opentripplanner/IntegrationTest.java b/src/test/java/org/opentripplanner/IntegrationTest.java
index fefd449..ca64587 100644
--- a/src/test/java/org/opentripplanner/IntegrationTest.java
+++ b/src/test/java/org/opentripplanner/IntegrationTest.java
@@ -98,19 +98,19 @@ public void planPlaceToPlaceWithSearchWindow() throws IOException {
.withSearchWindow(Duration.ofDays(1))
.build());
- LOG.info("Received {} itineraries", result.itineraries().size());
- assertEquals(1, result.itineraries().size());
+ LOG.info("Received {} itineraries", result.itineraries().size());
+ assertEquals(1, result.itineraries().size());
- assertNotNull(result.itineraries().get(0).legs().get(0).startTime());
+ assertNotNull(result.itineraries().get(0).legs().get(0).startTime());
- var leg = result.itineraries().get(0).legs().get(0);
+ var leg = result.itineraries().get(0).legs().get(0);
- var transitLeg = result.transitItineraries().get(0).transitLegs().get(0);
- assertFalse(transitLeg.from().stop().isEmpty());
- assertFalse(transitLeg.to().stop().isEmpty());
- assertNotNull(transitLeg.from().stop().get().id());
+ var transitLeg = result.transitItineraries().get(0).transitLegs().get(0);
+ assertFalse(transitLeg.from().stop().isEmpty());
+ assertFalse(transitLeg.to().stop().isEmpty());
+ assertNotNull(transitLeg.from().stop().get().id());
- assertEquals(List.of(), leg.fareProducts());
+ assertEquals(List.of(), leg.fareProducts());
}
@Test