diff options
Diffstat (limited to 'subprojects/store-partial/src/main/java/tools/refinery/store/partial/rule/RuleExecutor.java')
-rw-r--r-- | subprojects/store-partial/src/main/java/tools/refinery/store/partial/rule/RuleExecutor.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/subprojects/store-partial/src/main/java/tools/refinery/store/partial/rule/RuleExecutor.java b/subprojects/store-partial/src/main/java/tools/refinery/store/partial/rule/RuleExecutor.java new file mode 100644 index 00000000..41d79306 --- /dev/null +++ b/subprojects/store-partial/src/main/java/tools/refinery/store/partial/rule/RuleExecutor.java | |||
@@ -0,0 +1,34 @@ | |||
1 | package tools.refinery.store.partial.rule; | ||
2 | |||
3 | import tools.refinery.store.partial.MergeResult; | ||
4 | import tools.refinery.store.model.Model; | ||
5 | import tools.refinery.store.tuple.TupleLike; | ||
6 | |||
7 | import java.util.List; | ||
8 | |||
9 | public final class RuleExecutor { | ||
10 | private final Rule rule; | ||
11 | private final Model model; | ||
12 | private final List<RuleActionExecutor> actionExecutors; | ||
13 | |||
14 | RuleExecutor(Rule rule, Model model, List<RuleActionExecutor> actionExecutors) { | ||
15 | this.rule = rule; | ||
16 | this.model = model; | ||
17 | this.actionExecutors = actionExecutors; | ||
18 | } | ||
19 | |||
20 | public Rule getRule() { | ||
21 | return rule; | ||
22 | } | ||
23 | |||
24 | public Model getModel() { | ||
25 | return model; | ||
26 | } | ||
27 | public MergeResult execute(TupleLike activationTuple) { | ||
28 | MergeResult mergeResult = MergeResult.UNCHANGED; | ||
29 | for (var actionExecutor : actionExecutors) { | ||
30 | mergeResult = mergeResult.andAlso(actionExecutor.execute(activationTuple)); | ||
31 | } | ||
32 | return mergeResult; | ||
33 | } | ||
34 | } | ||