Skip to content

Commit

Permalink
Apply review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Jan 22, 2025
1 parent aa84c15 commit 5b5937d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ public class FlexibleTransitLeg implements TransitLeg {
this.fareProducts = List.copyOf(builder.fareProducts());
}

/**
* Return an empty builder for {@link FlexibleTransitLeg}.
*/
public static FlexibleTransitLegBuilder of() {
return new FlexibleTransitLegBuilder();
}

@Override
public Agency getAgency() {
return getTrip().getRoute().getAgency();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class FlexibleTransitLegBuilder {
private Set<TransitAlert> transitAlerts = new HashSet<>();
private List<FareProductUse> fareProducts = new ArrayList<>();

public FlexibleTransitLegBuilder() {}
FlexibleTransitLegBuilder() {}

public FlexibleTransitLegBuilder(FlexibleTransitLeg original) {
FlexibleTransitLegBuilder(FlexibleTransitLeg original) {
flexTripEdge = original.flexTripEdge();
startTime = original.getStartTime();
endTime = original.getEndTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.locationtech.jts.geom.LineString;
import org.locationtech.jts.geom.impl.PackedCoordinateSequence;
import org.opentripplanner.astar.model.GraphPath;
import org.opentripplanner.ext.flex.FlexibleTransitLegBuilder;
import org.opentripplanner.ext.flex.FlexibleTransitLeg;
import org.opentripplanner.ext.flex.edgetype.FlexTripEdge;
import org.opentripplanner.framework.application.OTPFeature;
import org.opentripplanner.framework.geometry.GeometryUtils;
Expand Down Expand Up @@ -336,7 +336,8 @@ private Leg generateFlexLeg(List<State> states) {
ZonedDateTime endTime = toState.getTime().atZone(timeZone);
int generalizedCost = (int) (toState.getWeight() - fromState.getWeight());

return new FlexibleTransitLegBuilder()
return FlexibleTransitLeg
.of()
.withFlexTripEdge(flexEdge)
.withStartTime(startTime)
.withEndTime(endTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.ArrayList;
import java.util.List;
import org.opentripplanner.ext.flex.FlexibleTransitLeg;
import org.opentripplanner.ext.flex.FlexibleTransitLegBuilder;
import org.opentripplanner.ext.flex.edgetype.FlexTripEdge;
import org.opentripplanner.ext.flex.flexpathcalculator.DirectFlexPathCalculator;
import org.opentripplanner.ext.flex.trip.UnscheduledTrip;
Expand Down Expand Up @@ -247,7 +246,8 @@ public TestItineraryBuilder flex(int start, int end, Place to) {
flexPath
);

FlexibleTransitLeg leg = new FlexibleTransitLegBuilder()
FlexibleTransitLeg leg = FlexibleTransitLeg
.of()
.withFlexTripEdge(edge)
.withStartTime(newTime(start))
.withEndTime(newTime(end))
Expand Down

0 comments on commit 5b5937d

Please sign in to comment.