Skip to content

Commit 490e2c2

Browse files
committed
fix/v3_beta_26: fix logic in PropertyOperationUtil.disablePropertyInPropertyQueryTree()
1 parent a2fa57f commit 490e2c2

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

here-naksha-lib-handlers/src/jvmMain/java/com/here/naksha/lib/handlers/util/PropertyOperationUtil.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import java.util.Collections;
2222
import java.util.HashSet;
23+
import java.util.List;
2324
import java.util.Set;
2425

2526
import com.here.naksha.lib.core.lambdas.F1;
@@ -63,18 +64,33 @@ private static void disablePropertyInPropertyQueryTree(
6364
@NotNull IPropertyQuery current, @Nullable IPropertyQuery parent, F1<Boolean, PQuery> removalCondition, Set<PQuery> disabledProperties
6465
) {
6566
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+
}
6981
case PQuery currentyPQuery when removalCondition.call(currentyPQuery) -> {
7082
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+
}
7488
} 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+
}
7894
} else if (parent instanceof PNot pNotParent) {
7995
pNotParent.setQuery(PFalse.INSTANCE);
8096
disabledProperties.add(currentyPQuery);

0 commit comments

Comments
 (0)