public interface Rule<T>
Rule is an interface that uses the following format:
rule.given(facts).when(some condition given facts).then(do something)| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
getThen()
Method getThen() gets an instance of a functional interface responsbile for the action to be performed by
the Rule.
|
java.util.function.Predicate<FactMap<T>> |
getWhen()
Method getWhen() gets the
Predicate that evaluates the condition of the Rule. |
Rule<T> |
given(Fact<T>... facts)
The given() method sets the Facts to be used by the Rule.
|
Rule<T> |
given(FactMap<T> facts)
The given() method sets the Facts to be used by the Rule.
|
Rule<T> |
given(java.util.List<Fact<T>> facts)
The given() method sets the Facts to be used by the Rule.
|
void |
run()
The run() method evaluates the Rule.
|
void |
setNextRule(Rule<T> rule)
The setNextRule method adds the next Rule to the chain.
|
Rule<T> |
then(java.util.function.Function<FactMap<T>,RuleState> action)
The then() method performs some action based on facts and returns a
RuleState of
either NEXT or BREAK. |
Rule<T> |
when(java.util.function.Predicate<FactMap<T>> test)
The when() method takes in a
Predicate that evaluates the facts against a condition. |
void run()
Rule<T> given(Fact<T>... facts)
facts - Facts to be used by the RuleRule<T> given(java.util.List<Fact<T>> facts)
facts - a List of Facts to be used by the RuleRule<T> given(FactMap<T> facts)
facts - a FactMapjava.util.function.Predicate<FactMap<T>> getWhen()
Predicate that evaluates the condition of the Rule.Rule<T> when(java.util.function.Predicate<FactMap<T>> test)
Predicate that evaluates the facts against a condition.test - the condition(s) to be evaluated against the Factsjava.lang.Object getThen()
Rule<T> then(java.util.function.Function<FactMap<T>,RuleState> action)
RuleState of
either NEXT or BREAK. If NEXT is returned then the next rule in the chain is executed.
If BREAK is returned then the chain is broken and no more rules are executed in the chain.action - the action to be performed