2 * SPDX-FileCopyrightText: The reguloj Authors
3 * SPDX-License-Identifier: 0BSD
5 package wtf
.metio
.reguloj
;
7 import java
.util
.Collection
;
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
> {
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.
25 public final boolean analyze(final Collection
<Rule
<CONTEXT
>> rules
, final CONTEXT context
) {
26 return rules
.stream().anyMatch(rule
-> rule
.fires(context
));