diff options
Diffstat (limited to 'subprojects/store/src/main/java/tools/refinery/store/query/internal/RelationalQueryMetaContext.java')
-rw-r--r-- | subprojects/store/src/main/java/tools/refinery/store/query/internal/RelationalQueryMetaContext.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/internal/RelationalQueryMetaContext.java b/subprojects/store/src/main/java/tools/refinery/store/query/internal/RelationalQueryMetaContext.java new file mode 100644 index 00000000..05fb0904 --- /dev/null +++ b/subprojects/store/src/main/java/tools/refinery/store/query/internal/RelationalQueryMetaContext.java | |||
@@ -0,0 +1,58 @@ | |||
1 | package tools.refinery.store.query.internal; | ||
2 | |||
3 | import java.util.Collection; | ||
4 | import java.util.Collections; | ||
5 | import java.util.HashMap; | ||
6 | import java.util.HashSet; | ||
7 | import java.util.Map; | ||
8 | import java.util.Set; | ||
9 | |||
10 | import org.eclipse.viatra.query.runtime.matchers.context.AbstractQueryMetaContext; | ||
11 | import org.eclipse.viatra.query.runtime.matchers.context.IInputKey; | ||
12 | import org.eclipse.viatra.query.runtime.matchers.context.InputKeyImplication; | ||
13 | |||
14 | import tools.refinery.store.query.view.RelationView; | ||
15 | |||
16 | /** | ||
17 | * The meta context information for String scopes. | ||
18 | */ | ||
19 | public final class RelationalQueryMetaContext extends AbstractQueryMetaContext { | ||
20 | |||
21 | @Override | ||
22 | public boolean isEnumerable(IInputKey key) { | ||
23 | ensureValidKey(key); | ||
24 | return key.isEnumerable(); | ||
25 | } | ||
26 | |||
27 | @Override | ||
28 | public boolean isStateless(IInputKey key) { | ||
29 | ensureValidKey(key); | ||
30 | return key instanceof RelationView<?>; | ||
31 | } | ||
32 | |||
33 | @Override | ||
34 | public Collection<InputKeyImplication> getImplications(IInputKey implyingKey) { | ||
35 | ensureValidKey(implyingKey); | ||
36 | return new HashSet<InputKeyImplication>(); | ||
37 | } | ||
38 | |||
39 | @Override | ||
40 | public Map<Set<Integer>, Set<Integer>> getFunctionalDependencies(IInputKey key) { | ||
41 | ensureValidKey(key); | ||
42 | if (key instanceof RelationView) { | ||
43 | return new HashMap<Set<Integer>, Set<Integer>>(); | ||
44 | } else { | ||
45 | return Collections.emptyMap(); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | public void ensureValidKey(IInputKey key) { | ||
50 | if (! (key instanceof RelationView<?>)) | ||
51 | illegalInputKey(key); | ||
52 | } | ||
53 | |||
54 | public void illegalInputKey(IInputKey key) { | ||
55 | throw new IllegalArgumentException("The input key " + key + " is not a valid input key."); | ||
56 | } | ||
57 | |||
58 | } | ||