diff --git a/src/main/java/org/opentripplanner/netex/validation/JourneyPatternSJMismatch.java b/src/main/java/org/opentripplanner/netex/validation/JourneyPatternSJMismatch.java index 216008621c3..28fc710a6ae 100644 --- a/src/main/java/org/opentripplanner/netex/validation/JourneyPatternSJMismatch.java +++ b/src/main/java/org/opentripplanner/netex/validation/JourneyPatternSJMismatch.java @@ -1,5 +1,6 @@ package org.opentripplanner.netex.validation; +import java.util.function.Predicate; import org.opentripplanner.graph_builder.issue.api.DataImportIssue; import org.rutebanken.netex.model.JourneyPattern_VersionStructure; import org.rutebanken.netex.model.PointInLinkSequence_VersionedChildStructure; @@ -7,6 +8,12 @@ import org.rutebanken.netex.model.StopPointInJourneyPattern; import org.rutebanken.netex.model.StopUseEnumeration; +/** + * Validates that the number of passing times in the journey and the number of stop points in the + * pattern are equal. + * It also takes into account that some points in the pattern can be set to stopUse=passthrough + * which means that those must not be referenced in the journey. + */ class JourneyPatternSJMismatch extends AbstractHMapValidationRule { @Override @@ -19,7 +26,7 @@ public Status validate(ServiceJourney sj) { .getPointsInSequence() .getPointInJourneyPatternOrStopPointInJourneyPatternOrTimingPointInJourneyPattern() .stream() - .filter(JourneyPatternSJMismatch::stopsAtQuay) + .filter(Predicate.not(JourneyPatternSJMismatch::isPassThrough)) .count(); int nTimetablePassingTimes = sj.getPassingTimes().getTimetabledPassingTime().size(); @@ -27,11 +34,15 @@ public Status validate(ServiceJourney sj) { return nStopPointsInJourneyPattern != nTimetablePassingTimes ? Status.DISCARD : Status.OK; } - private static boolean stopsAtQuay(PointInLinkSequence_VersionedChildStructure point) { - return switch (point) { - case StopPointInJourneyPattern spijp -> spijp.getStopUse() != StopUseEnumeration.PASSTHROUGH; - default -> true; - }; + /** + * Does the stop point in the sequence represent a stop where the vehicle passes through without + * stopping? + */ + private static boolean isPassThrough(PointInLinkSequence_VersionedChildStructure point) { + return ( + point instanceof StopPointInJourneyPattern spijp && + spijp.getStopUse() == StopUseEnumeration.PASSTHROUGH + ); } @Override