package com.conveyal.r5.analyst.scenario;

import com.conveyal.r5.transit.TripPattern;
import com.conveyal.r5.transit.TripSchedule;

/**
 * Remove trips from a scenario.
 * This could remove all trips on a route, since its superclass TimetableFilter provides both route and trip matching.
 */
public class RemoveTrip extends TripScheduleModification {

    public static final long serialVersionUID = 1L;

    @Override
    public String getType() {
        return "remove-trip";
    }

    @Override
    public TripSchedule applyToTripSchedule(TripPattern tripPattern, TripSchedule tripSchedule) {
        return matches(tripSchedule.tripId) ? null : tripSchedule;
    }

}

@@ -126,16 +126,43 @@
 edule;%0A%0A
+import java.util.Objects;%0A%0A
 /**%0A * R
@@ -507,16 +507,830 @@
 %0A    %7D%0A%0A
+    @Override%0A    public TripPattern applyToTripPattern(TripPattern originalTripPattern) %7B%0A        // Check first whether it's even possible that this Modification will apply to any trips on this pattern%0A        if (!couldMatch(originalTripPattern)) %7B%0A            return originalTripPattern;%0A        %7D%0A        // Stopgap efficient check for route filtration.%0A        // All trips on a TripPattern are on the same route so we can remove them all at once.%0A        if (routeId != null && (tripId == null %7C%7C tripId.isEmpty())) %7B%0A            if (routeId.contains(originalTripPattern.routeId)) %7B%0A                return null;%0A            %7D%0A        %7D%0A        // Actually apply the Modification to each TripSchedule within this TripPattern individually.%0A        return super.applyToTripPattern(originalTripPattern);%0A    %7D%0A%0A
     @Ove

remove entire trip patterns when routes are filtered