aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/actions/FocusActionLiteral.java
blob: 5a6f22d23c4295b2cc60d40de4ee7310a4d959b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.store.reasoning.actions;

import tools.refinery.store.dse.transition.actions.AbstractActionLiteral;
import tools.refinery.store.dse.transition.actions.BoundActionLiteral;
import tools.refinery.store.model.Model;
import tools.refinery.store.query.term.NodeVariable;
import tools.refinery.store.reasoning.ReasoningAdapter;

import java.util.List;

public class FocusActionLiteral extends AbstractActionLiteral {
	private final NodeVariable parentNode;
	private final NodeVariable childNode;

	public FocusActionLiteral(NodeVariable parentNode, NodeVariable childNode) {
		this.parentNode = parentNode;
		this.childNode = childNode;
	}

	public NodeVariable getParentNode() {
		return parentNode;
	}

	public NodeVariable getChildNode() {
		return childNode;
	}

	@Override
	public List<NodeVariable> getInputVariables() {
		return List.of(parentNode);
	}

	@Override
	public List<NodeVariable> getOutputVariables() {
		return List.of(childNode);
	}

	@Override
	public BoundActionLiteral bindToModel(Model model) {
		var reasoningAdapter = model.getAdapter(ReasoningAdapter.class);
		return tuple -> reasoningAdapter.focus(tuple.get(0));
	}
}