Skip to content

Commit

Permalink
rename the enum again
Browse files Browse the repository at this point in the history
  • Loading branch information
miklcct committed Nov 11, 2024
1 parent e129934 commit ac912a6
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.opentripplanner.routing.alertpatch.TransitAlert;
import org.opentripplanner.routing.alternativelegs.AlternativeLegs;
import org.opentripplanner.routing.alternativelegs.AlternativeLegsFilter;
import org.opentripplanner.routing.alternativelegs.SearchTime;
import org.opentripplanner.routing.alternativelegs.NavigationDirection;
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.organization.Agency;
import org.opentripplanner.transit.model.timetable.Trip;
Expand Down Expand Up @@ -278,15 +278,15 @@ private Leg getSource(DataFetchingEnvironment environment) {

@Override
public DataFetcher<Iterable<Leg>> previousLegs() {
return alternativeLegs(SearchTime.BEFORE);
return alternativeLegs(NavigationDirection.PREVIOUS);
}

@Override
public DataFetcher<Iterable<Leg>> nextLegs() {
return alternativeLegs(SearchTime.AFTER);
return alternativeLegs(NavigationDirection.NEXT);
}

private DataFetcher<Iterable<Leg>> alternativeLegs(SearchTime timeLine) {
private DataFetcher<Iterable<Leg>> alternativeLegs(NavigationDirection timeLine) {
return environment -> {
if (environment.getSource() instanceof ScheduledTransitLeg originalLeg) {
var args = new GraphQLTypes.GraphQLLegNextLegsArgs(environment.getArguments());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.opentripplanner.model.plan.TransitLeg;
import org.opentripplanner.model.plan.legreference.LegReferenceSerializer;
import org.opentripplanner.routing.alternativelegs.AlternativeLegs;
import org.opentripplanner.routing.alternativelegs.SearchTime;
import org.opentripplanner.routing.alternativelegs.NavigationDirection;

public class LegType {

Expand Down Expand Up @@ -486,7 +486,7 @@ public static GraphQLObjectType create(
leg,
env.getArgument("previous"),
GqlUtil.getTransitService(env),
SearchTime.BEFORE,
NavigationDirection.PREVIOUS,
env.getArgument("filter")
);
})
Expand Down Expand Up @@ -526,7 +526,7 @@ public static GraphQLObjectType create(
leg,
env.getArgument("next"),
GqlUtil.getTransitService(env),
SearchTime.AFTER,
NavigationDirection.NEXT,
env.getArgument("filter")
);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static List<ScheduledTransitLeg> getAlternativeLegs(
Leg leg,
Integer numberLegs,
TransitService transitService,
SearchTime timeLine,
NavigationDirection timeLine,
AlternativeLegsFilter filter
) {
return getAlternativeLegs(leg, numberLegs, transitService, timeLine, filter, false, false);
Expand Down Expand Up @@ -73,7 +73,7 @@ public static List<ScheduledTransitLeg> getAlternativeLegs(
Leg leg,
Integer numberLegs,
TransitService transitService,
SearchTime timeLine,
NavigationDirection timeLine,
AlternativeLegsFilter filter,
boolean exactOriginStop,
boolean exactDestinationStop
Expand All @@ -96,7 +96,7 @@ public static List<ScheduledTransitLeg> getAlternativeLegs(
ScheduledTransitLeg::getStartTime
);

if (timeLine == SearchTime.BEFORE) {
if (timeLine == NavigationDirection.PREVIOUS) {
legComparator = legComparator.reversed();
}

Expand Down Expand Up @@ -127,7 +127,7 @@ private static Stream<ScheduledTransitLeg> generateLegs(
TripPatternBetweenStops tripPatternBetweenStops,
ZonedDateTime departureTime,
LocalDate originalDate,
SearchTime timeLine
NavigationDirection timeLine
) {
TripPattern pattern = tripPatternBetweenStops.tripPattern;
int boardingPosition = tripPatternBetweenStops.positions.boardingPosition;
Expand All @@ -140,7 +140,7 @@ private static Stream<ScheduledTransitLeg> generateLegs(
tts.getServiceDayMidnight() + tts.getRealtimeDeparture()
);

if (timeLine == SearchTime.BEFORE) {
if (timeLine == NavigationDirection.PREVIOUS) {
comparator = comparator.reversed();
}

Expand Down Expand Up @@ -170,7 +170,7 @@ private static Stream<ScheduledTransitLeg> generateLegs(
continue;
}

boolean departureTimeInRange = timeLine == SearchTime.BEFORE
boolean departureTimeInRange = timeLine == NavigationDirection.PREVIOUS
? tripTimes.getDepartureTime(boardingPosition) <= secondsSinceMidnight
: tripTimes.getDepartureTime(boardingPosition) >= secondsSinceMidnight;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.opentripplanner.routing.alternativelegs;

/**
* This enum describes how the user navigates on a list of items.
*/
public enum NavigationDirection {
/**
* Get the next set of items.
*/
NEXT,
/**
* Get the previous set of items.
*/
PREVIOUS,
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.opentripplanner.model.plan.legreference.ScheduledTransitLegReference;
import org.opentripplanner.routing.alternativelegs.AlternativeLegs;
import org.opentripplanner.routing.alternativelegs.AlternativeLegsFilter;
import org.opentripplanner.routing.alternativelegs.SearchTime;
import org.opentripplanner.routing.alternativelegs.NavigationDirection;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.service.DefaultTransitService;

Expand Down Expand Up @@ -52,7 +52,7 @@ void testPreviousLegs() {
originalLeg,
3,
transitService,
SearchTime.BEFORE,
NavigationDirection.PREVIOUS,
AlternativeLegsFilter.NO_FILTER
);

Expand Down Expand Up @@ -86,7 +86,7 @@ void testNextLegs() {
originalLeg,
3,
transitService,
SearchTime.AFTER,
NavigationDirection.NEXT,
AlternativeLegsFilter.NO_FILTER
);

Expand Down Expand Up @@ -120,7 +120,7 @@ void testCircularRoutes() {
originalLeg,
2,
transitService,
SearchTime.AFTER,
NavigationDirection.NEXT,
AlternativeLegsFilter.NO_FILTER
);

Expand Down Expand Up @@ -148,7 +148,7 @@ void testComplexCircularRoutes() {
originalLeg,
2,
transitService,
SearchTime.AFTER,
NavigationDirection.NEXT,
AlternativeLegsFilter.NO_FILTER
);
var legs = toString(alternativeLegs);
Expand Down

0 comments on commit ac912a6

Please sign in to comment.