update copyright
[reguloj.git] / src / main / java / wtf / metio / reguloj / ChainedRuleEngine.java
blobf9a186499d528c4d0dc2bd909467998dd6cbb63f
1 /*
2 * This file is part of reguloj. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at https://creativecommons.org/publicdomain/zero/1.0/. No part of reguloj,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
5 * in the LICENSE file.
6 */
8 package wtf.metio.reguloj;
10 import java.util.Collection;
12 /**
13 * Chained rule engine that repeatedly runs all rules until no rule fires anymore.
15 * @param <CONTEXT> The type of the context.
16 * @see FirstWinsRuleEngine
17 * @see LimitedRuleEngine
19 final class ChainedRuleEngine<CONTEXT extends Context<?>> extends AbstractRuleEngine<CONTEXT> {
21 @Override
22 public void infer(final Collection<Rule<CONTEXT>> rules, final CONTEXT context) {
23 while (analyze(rules, context)) {
24 rules.forEach(rule -> rule.run(context));