File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
raptor/src/main/java/org/opentripplanner/raptor/api/request Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 33import java .time .Duration ;
44import java .util .ArrayList ;
55import java .util .BitSet ;
6+ import java .util .HashSet ;
67import java .util .List ;
78import java .util .stream .IntStream ;
89import javax .annotation .Nullable ;
@@ -138,18 +139,21 @@ private List<RaptorViaConnection> validateConnections(List<BuilderStopAndTransfe
138139 .toList ();
139140
140141 // Compare all pairs to check for duplicates and non-optimal connections
142+ var connectionsToRemove = new HashSet <RaptorViaConnection >();
141143 for (int i = 0 ; i < list .size (); ++i ) {
142144 var a = list .get (i );
143145 for (int j = i + 1 ; j < list .size (); ++j ) {
144146 var b = list .get (j );
145- if (a .isBetterOrEqual (b ) || b .isBetterOrEqual (a )) {
146- throw new IllegalArgumentException (
147- "All connection need to be pareto-optimal: (" + a + ") <-> (" + b + ")"
148- );
147+ if (a .isBetterOrEqual (b )) {
148+ connectionsToRemove .add (b );
149+ continue ;
150+ }
151+ if (b .isBetterOrEqual (a )) {
152+ connectionsToRemove .add (a );
149153 }
150154 }
151155 }
152- return list ;
156+ return list . stream (). filter ( connection -> ! connectionsToRemove . contains ( connection )). toList () ;
153157 }
154158
155159 public abstract static sealed class AbstractBuilder <T extends AbstractBuilder > {
You can’t perform that action at this time.
0 commit comments