|
20 | 20 |
|
21 | 21 | import java.util.Collections; |
22 | 22 | import java.util.HashSet; |
| 23 | +import java.util.List; |
23 | 24 | import java.util.Set; |
24 | 25 |
|
25 | 26 | import com.here.naksha.lib.core.lambdas.F1; |
@@ -63,18 +64,33 @@ private static void disablePropertyInPropertyQueryTree( |
63 | 64 | @NotNull IPropertyQuery current, @Nullable IPropertyQuery parent, F1<Boolean, PQuery> removalCondition, Set<PQuery> disabledProperties |
64 | 65 | ) { |
65 | 66 | switch (current) { |
66 | | - case PAnd pAnd -> pAnd.forEach(andChild -> disablePropertyInPropertyQueryTree(andChild, pAnd, removalCondition, disabledProperties)); |
67 | | - case POr pOr -> pOr.forEach(orChild -> disablePropertyInPropertyQueryTree(orChild, pOr, removalCondition, disabledProperties)); |
68 | | - case PNot pNot -> disablePropertyInPropertyQueryTree(pNot.getQuery(), pNot, removalCondition, disabledProperties); |
| 67 | + case PAnd pAnd -> { |
| 68 | + for (var andChild : pAnd) { |
| 69 | + disablePropertyInPropertyQueryTree(andChild, pAnd, removalCondition, disabledProperties); |
| 70 | + } |
| 71 | + } |
| 72 | + case POr pOr -> { |
| 73 | + for (var orChild : pOr) { |
| 74 | + disablePropertyInPropertyQueryTree(orChild, pOr, removalCondition, disabledProperties); |
| 75 | + } |
| 76 | + } |
| 77 | + case PNot pNot -> { |
| 78 | + disablePropertyInPropertyQueryTree(pNot.getQuery(), pNot, removalCondition, disabledProperties); |
| 79 | + |
| 80 | + } |
69 | 81 | case PQuery currentyPQuery when removalCondition.call(currentyPQuery) -> { |
70 | 82 | if (parent instanceof PAnd pAndParent) { |
71 | | - pAndParent.remove(current); |
72 | | - pAndParent.add(PTrue.INSTANCE); |
73 | | - disabledProperties.add(currentyPQuery); |
| 83 | + int idx = pAndParent.indexOf(current); |
| 84 | + if (idx >= 0) { |
| 85 | + pAndParent.set(idx, PTrue.INSTANCE); |
| 86 | + disabledProperties.add(currentyPQuery); |
| 87 | + } |
74 | 88 | } else if (parent instanceof POr pOrParent) { |
75 | | - pOrParent.remove(current); |
76 | | - pOrParent.add(PTrue.INSTANCE); |
77 | | - disabledProperties.add(currentyPQuery); |
| 89 | + int idx = pOrParent.indexOf(current); |
| 90 | + if (idx >= 0) { |
| 91 | + pOrParent.set(idx, PTrue.INSTANCE); |
| 92 | + disabledProperties.add(currentyPQuery); |
| 93 | + } |
78 | 94 | } else if (parent instanceof PNot pNotParent) { |
79 | 95 | pNotParent.setQuery(PFalse.INSTANCE); |
80 | 96 | disabledProperties.add(currentyPQuery); |
|
0 commit comments