aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/viewupdate/ViewUpdateTranslator.java
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/viewupdate/ViewUpdateTranslator.java')
-rw-r--r--subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/viewupdate/ViewUpdateTranslator.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/viewupdate/ViewUpdateTranslator.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/viewupdate/ViewUpdateTranslator.java
index 2f7f9a9c..62a10e45 100644
--- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/viewupdate/ViewUpdateTranslator.java
+++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/viewupdate/ViewUpdateTranslator.java
@@ -1,5 +1,6 @@
1package tools.refinery.store.query.viatra.internal.viewupdate; 1package tools.refinery.store.query.viatra.internal.viewupdate;
2 2
3import org.eclipse.viatra.query.runtime.matchers.context.IInputKey;
3import org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContextListener; 4import org.eclipse.viatra.query.runtime.matchers.context.IQueryRuntimeContextListener;
4import org.eclipse.viatra.query.runtime.matchers.tuple.ITuple; 5import org.eclipse.viatra.query.runtime.matchers.tuple.ITuple;
5import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; 6import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
@@ -9,29 +10,38 @@ import tools.refinery.store.query.view.RelationView;
9import java.util.Objects; 10import java.util.Objects;
10 11
11public class ViewUpdateTranslator<D> { 12public class ViewUpdateTranslator<D> {
13 private final IInputKey wrappedKey;
14
12 private final RelationView<D> key; 15 private final RelationView<D> key;
13 16
14 private final ITuple filter; 17 private final ITuple filter;
15 18
16 private final IQueryRuntimeContextListener listener; 19 private final IQueryRuntimeContextListener listener;
17 20
18 public ViewUpdateTranslator(RelationView<D> key, ITuple filter, IQueryRuntimeContextListener listener) { 21 public ViewUpdateTranslator(IInputKey wrappedKey, RelationView<D> key, ITuple filter,
22 IQueryRuntimeContextListener listener) {
19 super(); 23 super();
24 this.wrappedKey = wrappedKey;
20 this.key = key; 25 this.key = key;
21 this.filter = filter; 26 this.filter = filter;
22 this.listener = listener; 27 this.listener = listener;
23 } 28 }
24 29
25 public boolean equals(RelationView<?> relationView, ITuple seed, IQueryRuntimeContextListener listener) { 30 public boolean equals(IInputKey wrappedKey, RelationView<?> relationView, ITuple seed,
26 return key == relationView && filter.equals(seed) && this.listener == listener; 31 IQueryRuntimeContextListener listener) {
32 return this.wrappedKey == wrappedKey && key == relationView && filter.equals(seed) && this.listener == listener;
27 } 33 }
28 34
29 public void processChange(ViewUpdate change) { 35 public void processChange(ViewUpdate change) {
30 listener.update(key, Tuples.flatTupleOf(change.tuple()), change.isInsertion()); 36 listener.update(wrappedKey, Tuples.flatTupleOf(change.tuple()), change.isInsertion());
31 } 37 }
32 38
39 @SuppressWarnings("squid:S1168")
33 public Object[] isMatching(Tuple tuple, D value) { 40 public Object[] isMatching(Tuple tuple, D value) {
34 return isMatching(key.getWrappedKey().transform(tuple, value), filter); 41 if (!key.filter(tuple, value)) {
42 return null;
43 }
44 return isMatching(key.forwardMap(tuple, value), filter);
35 } 45 }
36 46
37 @SuppressWarnings("squid:S1168") 47 @SuppressWarnings("squid:S1168")