public interface ConditionManager
Previously part of the
RuleBuilder interface, since version 4.0.0, this interface contains methods
for declaring various rule-level conditions and obtaining their references. These references can later be used
in the EvaluatorsContext methods to replace existing conditions on the fly or to subscribe to
evaluation events.
If you don't need these condition handles, it is better to use the standard
where(...) methods of LhsBuilder, which provide the same functionality,
and offer a more fluent API compared to this interface.
-
Method Summary
Modifier and TypeMethodDescriptiondefault CompletableFuture<EvaluatorHandle>addCondition(String expression) Compiles and adds the provided literal predicate to the currentRuleBuilderas a new condition.addCondition(String expression, double complexity) Compiles and adds the provided literal predicate to the currentRuleBuilderas a new condition.addCondition(Predicate<Object[]> predicate, double complexity, String... references) Adds the provided predicate to the currentRuleBuilderas a new condition.default EvaluatorHandleaddCondition(Predicate<Object[]> predicate, String... references) Adds the provided predicate to the currentRuleBuilderas a new condition.addCondition(ValuesPredicate predicate, double complexity, String... references) Adds the provided predicate to the currentRuleBuilderas a new condition.default EvaluatorHandleaddCondition(ValuesPredicate predicate, String... references) Adds the provided predicate to the currentRuleBuilderas a new condition.
-
Method Details
-
addCondition
Adds the provided predicate to the currentRuleBuilderas a new condition. The resultingEvaluatorHandlecan later be provided to theEvaluatorsContext.replacePredicate(EvaluatorHandle, ValuesPredicate)method to replace conditions on the fly or subscribe to evaluation events.The provided references must be of the same order and type as expected by the predicate argument.
- Parameters:
predicate- the condition predicatecomplexity- the condition's relative complexityreferences- the field references, e.g.,["$a.id", "$b.code.value", "$c"]- Returns:
- the evaluator handle
- See Also:
-
addCondition
Adds the provided predicate to the currentRuleBuilderas a new condition. The resultingEvaluatorHandlecan later be provided to theEvaluatorsContext.replacePredicate(EvaluatorHandle, ValuesPredicate)method to replace conditions on the fly or subscribe to evaluation events.The provided references must be of the same order and type as expected by the predicate argument.
- Parameters:
predicate- the condition predicatereferences- the field references, e.g.,["$a.id", "$b.code.value", "$c"]- Returns:
- the evaluator handle
- See Also:
-
addCondition
EvaluatorHandle addCondition(Predicate<Object[]> predicate, double complexity, String... references) Adds the provided predicate to the currentRuleBuilderas a new condition. The resultingEvaluatorHandlecan later be provided to theEvaluatorsContext.replacePredicate(EvaluatorHandle, ValuesPredicate)method to replace conditions on the fly or subscribe to evaluation events.The provided references must be of the same order and type as expected by the predicate argument.
- Parameters:
predicate- the condition predicatecomplexity- the condition's relative complexityreferences- the field references, e.g.,["$a.id", "$b.code.value", "$c"]- Returns:
- the evaluator handle
- See Also:
-
addCondition
Adds the provided predicate to the currentRuleBuilderas a new condition. The resultingEvaluatorHandlecan later be provided to theEvaluatorsContext.replacePredicate(EvaluatorHandle, ValuesPredicate)method to replace conditions on the fly or subscribe to evaluation events.The provided references must be of the same order and type as expected by the predicate argument.
- Parameters:
predicate- the condition predicatereferences- the field references, e.g.,["$a.id", "$b.code.value", "$c"]- Returns:
- the evaluator handle
- See Also:
-
addCondition
Compiles and adds the provided literal predicate to the currentRuleBuilderas a new condition. Unlike otheraddConditionmethods, this method returns aCompletableFuturewhich will be available after theRuleSetBuilder.build()method is called. The resultingEvaluatorHandlecan later be provided to theEvaluatorsContext.replacePredicate(EvaluatorHandle, ValuesPredicate)method to replace conditions on the fly or subscribe to evaluation events.- Parameters:
expression- the literal condition, e.g.,$a.value > $c.code.valuecomplexity- the condition's relative complexity- Returns:
- a
CompletableFuturerepresenting theEvaluatorHandlethat will be available when the current ruleset is built. - See Also:
-
addCondition
Compiles and adds the provided literal predicate to the currentRuleBuilderas a new condition. Unlike otheraddConditionmethods, this method returns aCompletableFuturewhich will be available after theRuleSetBuilder.build()method is called. The resultingEvaluatorHandlecan later be provided to theEvaluatorsContext.replacePredicate(EvaluatorHandle, ValuesPredicate)method to replace conditions on the fly or subscribe to evaluation events.- Parameters:
expression- the literal condition, e.g.,$a.value > $c.code.value- Returns:
- a
CompletableFuturerepresenting theEvaluatorHandlethat will be available when the current ruleset is built. - See Also:
-