update project metadata
[reguloj.git] / src / main / java / wtf / metio / reguloj / AbstractRuleEngine.java
blobaeb05ed729f6d56b9952daf5e4810647c2e76246
1 /*
2 * SPDX-FileCopyrightText: The reguloj Authors
3 * SPDX-License-Identifier: 0BSD
4 */
5 package wtf.metio.reguloj;
7 import java.util.Collection;
9 /**
10 * Abstract rule engine which provides an implementation for the {@link #analyze(Collection, Context)} method. Therefore
11 * implementors only have to write the {@link #infer(Collection, Context)} method.
13 * @param <CONTEXT> The context type.
15 public abstract class AbstractRuleEngine<CONTEXT extends Context<?>> implements RuleEngine<CONTEXT> {
17 /**
18 * Checks whether a single rule fires for the given context.
20 * @param rules The rules to check.
21 * @param context The context to use.
22 * @return true if any rule fired, false otherwise.
24 @Override
25 public final boolean analyze(final Collection<Rule<CONTEXT>> rules, final CONTEXT context) {
26 return rules.stream().anyMatch(rule -> rule.fires(context));