Skip to content

Commit

Permalink
Clean up after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Mar 12, 2024
1 parent ea47a56 commit 505fefd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 76 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
<version>2.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.0.0-jre</version>
</dependency>

<!-- Test -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,8 +18,7 @@ public final class TripPlanParameters {
private final int numItineraries;
private final Set<RequestMode> modes;
private final SearchDirection searchDirection;
@Nullable
private final Duration searchWindow;
@Nullable private final Duration searchWindow;
private final float walkReluctance;
private final boolean wheelchair;

Expand All @@ -30,17 +29,15 @@ public TripPlanParameters(
int numItineraries,
Set<RequestMode> 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;
Expand Down Expand Up @@ -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();
}
}
18 changes: 9 additions & 9 deletions src/test/java/org/opentripplanner/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 505fefd

Please sign in to comment.