diff options
Diffstat (limited to 'subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/actions/FocusActionLiteral.java')
-rw-r--r-- | subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/actions/FocusActionLiteral.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/actions/FocusActionLiteral.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/actions/FocusActionLiteral.java new file mode 100644 index 00000000..5a6f22d2 --- /dev/null +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/actions/FocusActionLiteral.java | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | package tools.refinery.store.reasoning.actions; | ||
7 | |||
8 | import tools.refinery.store.dse.transition.actions.AbstractActionLiteral; | ||
9 | import tools.refinery.store.dse.transition.actions.BoundActionLiteral; | ||
10 | import tools.refinery.store.model.Model; | ||
11 | import tools.refinery.store.query.term.NodeVariable; | ||
12 | import tools.refinery.store.reasoning.ReasoningAdapter; | ||
13 | |||
14 | import java.util.List; | ||
15 | |||
16 | public class FocusActionLiteral extends AbstractActionLiteral { | ||
17 | private final NodeVariable parentNode; | ||
18 | private final NodeVariable childNode; | ||
19 | |||
20 | public FocusActionLiteral(NodeVariable parentNode, NodeVariable childNode) { | ||
21 | this.parentNode = parentNode; | ||
22 | this.childNode = childNode; | ||
23 | } | ||
24 | |||
25 | public NodeVariable getParentNode() { | ||
26 | return parentNode; | ||
27 | } | ||
28 | |||
29 | public NodeVariable getChildNode() { | ||
30 | return childNode; | ||
31 | } | ||
32 | |||
33 | @Override | ||
34 | public List<NodeVariable> getInputVariables() { | ||
35 | return List.of(parentNode); | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public List<NodeVariable> getOutputVariables() { | ||
40 | return List.of(childNode); | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | public BoundActionLiteral bindToModel(Model model) { | ||
45 | var reasoningAdapter = model.getAdapter(ReasoningAdapter.class); | ||
46 | return tuple -> reasoningAdapter.focus(tuple.get(0)); | ||
47 | } | ||
48 | } | ||