From 4a01328ab31f1c49060d3df33c4b390d90cc3a01 Mon Sep 17 00:00:00 2001 From: Ville Pihlava Date: Thu, 12 Dec 2024 12:34:11 +0200 Subject: [PATCH] Refactor to use method. --- .../src/ext/java/org/opentripplanner/ext/flex/FlexIndex.java | 4 +--- .../opentripplanner/transit/service/TimetableRepository.java | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/FlexIndex.java b/application/src/ext/java/org/opentripplanner/ext/flex/FlexIndex.java index ccc4f7fe554..73259fbc80e 100644 --- a/application/src/ext/java/org/opentripplanner/ext/flex/FlexIndex.java +++ b/application/src/ext/java/org/opentripplanner/ext/flex/FlexIndex.java @@ -30,9 +30,7 @@ public class FlexIndex { public FlexIndex(TimetableRepository timetableRepository) { // Flex transfers should only use WALK mode transfers. - StreetMode mode = StreetMode.WALK; - List filteredPathTransfers = timetableRepository.getAllPathTransfers().stream().filter(pathTransfer -> pathTransfer.getModes().contains(mode)).toList(); - for (PathTransfer transfer : filteredPathTransfers) { + for (PathTransfer transfer : timetableRepository.getTransfersByMode(StreetMode.WALK)) { transfersToStop.put(transfer.to, transfer); transfersFromStop.put(transfer.from, transfer); } diff --git a/application/src/main/java/org/opentripplanner/transit/service/TimetableRepository.java b/application/src/main/java/org/opentripplanner/transit/service/TimetableRepository.java index d83c3f9b996..7ef6da379f1 100644 --- a/application/src/main/java/org/opentripplanner/transit/service/TimetableRepository.java +++ b/application/src/main/java/org/opentripplanner/transit/service/TimetableRepository.java @@ -16,6 +16,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -434,7 +435,7 @@ public Collection getTransfersByStop(StopLocation stop) { return transfersByStop.get(stop); } - public Collection getTransfersByMode(StreetMode mode) { + public List getTransfersByMode(StreetMode mode) { return transfersByStop .values() .stream()