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
8 package wtf
.metio
.reguloj
;
10 import java
.util
.function
.Consumer
;
11 import java
.util
.function
.Predicate
;
14 * Implementation of the {@link Rule} interface that uses the java.util.function package.
16 * @param <CONTEXT> The type of the context.
17 * @see java.util.function.Predicate
18 * @see java.util.function.Consumer
20 record JavaUtilFunctionRule
<CONTEXT
extends Context
<?
>>(
22 Predicate
<CONTEXT
> predicate
,
23 Consumer
<CONTEXT
> consumer
) implements Rule
<CONTEXT
> {
26 public void run(final CONTEXT context
) {
28 consumer
.accept(context
);
33 public boolean fires(final CONTEXT context
) {
34 return predicate
.test(context
);