| Constructor and Description |
|---|
StandardRule() |
| Modifier and Type | Method and Description |
|---|---|
static StandardRule<java.lang.Object> |
create()
This create() method is a convenience method to create a non-type specific StandardRule.
|
static <T> StandardRule<T> |
create(java.lang.Class<T> factType)
This create() method is a convenience method to avoid using new and generic syntax.
|
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 accepts Facts to be evaluated in the Rule.
|
Rule<T> |
given(FactMap<T> facts)
The given() method accepts Facts to be evaluated in the Rule.
|
Rule<T> |
given(java.util.List<Fact<T>> facts)
The given() method accepts Facts to be evaluated in the Rule.
|
void |
run()
The run() method runs the
Predicate supplied by the when() method. |
void |
setNextRule(Rule<T> rule)
The setNextRule() method sets the next Rule in the chain.
|
Rule<T> |
then(java.util.function.Function<FactMap<T>,RuleState> action)
The then() method accepts a
Function that performs an action based on Facts and then returns a
RuleState of either NEXT or BREAK. |
Rule<T> |
when(java.util.function.Predicate<FactMap<T>> test)
The when() method accepts a
Predicate that returns true or false based on Facts. |
public static <T> StandardRule<T> create(java.lang.Class<T> factType)
T - the type of FactfactType - the type of object stored in facts for this Rulepublic static StandardRule<java.lang.Object> create()
public void run()
Predicate supplied by the when() method. If it evaluates to true then
the Function supplied by the then() method is executed. If the then()
method returns a BREAK RuleState then no further rules are evaluated. Otherwise, the next rule in the
chain is evaluated.public Rule<T> given(Fact<T>... facts)
public Rule<T> given(java.util.List<Fact<T>> facts)
public Rule<T> given(FactMap<T> facts)
public Rule<T> when(java.util.function.Predicate<FactMap<T>> test)
Predicate that returns true or false based on Facts.public Rule<T> then(java.util.function.Function<FactMap<T>,RuleState> action)
Function that performs an action based on Facts and then returns a
RuleState of either NEXT or BREAK.public void setNextRule(Rule<T> rule)
setNextRule in interface Rule<T>rule - the next Rule to add to the chainpublic java.util.function.Predicate<FactMap<T>> getWhen()
RulePredicate that evaluates the condition of the Rule.