Skip to content

Commit

Permalink
Refactor to use method.
Browse files Browse the repository at this point in the history
  • Loading branch information
VillePihlava committed Dec 12, 2024
1 parent 3ae6eed commit 4a01328
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public class FlexIndex {

public FlexIndex(TimetableRepository timetableRepository) {
// Flex transfers should only use WALK mode transfers.
StreetMode mode = StreetMode.WALK;
List<PathTransfer> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -434,7 +435,7 @@ public Collection<PathTransfer> getTransfersByStop(StopLocation stop) {
return transfersByStop.get(stop);
}

public Collection<PathTransfer> getTransfersByMode(StreetMode mode) {
public List<PathTransfer> getTransfersByMode(StreetMode mode) {
return transfersByStop
.values()
.stream()
Expand Down

0 comments on commit 4a01328

Please sign in to comment.