public class StandardDecision<T,U> extends java.lang.Object implements Decision<T,U>
Decision.| Constructor and Description |
|---|
StandardDecision() |
| Modifier and Type | Method and Description |
|---|---|
static StandardDecision<java.lang.Object,java.lang.Object> |
create()
This create() method is another convenience method to create a non-type specific StandardDecision.
|
static <T,U> StandardDecision<T,U> |
create(java.lang.Class<T> factType,
java.lang.Class<U> returnType)
This create() method is a convenience method to avoid using new and generic syntax.
|
FactMap<T> |
getFactMap()
The getFactMap() method gets the factMap of stored facts.
|
U |
getResult()
The getResult() method gets the stored Result value from the execution of the StandardDecision.
|
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. |
StandardDecision<T,U> |
given(Fact<T>... facts)
The given() method accepts Facts for the StandardDecision.
|
StandardDecision<T,U> |
given(FactMap<T> facts)
The given() method accepts Facts for the StandardDecision.
|
StandardDecision<T,U> |
given(java.util.List<Fact<T>> facts)
The given() method accepts Facts for the StandardDecision.
|
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.
|
void |
setResult(Result<U> result)
The setResult() method sets the stored Result.
|
StandardDecision<T,U> |
then(java.util.function.BiFunction<FactMap<T>,Result<U>,RuleState> action)
|
StandardDecision<T,U> |
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. |
StandardDecision<T,U> |
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,U> StandardDecision<T,U> create(java.lang.Class<T> factType, java.lang.Class<U> returnType)
T - the class type of the objects in the Facts usedU - the class type of object stored in the ResultfactType - the type of object stored in facts for this DecisionreturnType - the type of the stored Resultpublic static StandardDecision<java.lang.Object,java.lang.Object> create()
public void run()
Predicate supplied by the when() method.
If it evaluates to true then the BiFunction supplied by the then() method is executed.
If the BiFuction is not available then the Function is called instead. If the then() method returns a
BREAK RuleState then no further rules are evaluated, otherwise the next rule in the chain is evaluated.public StandardDecision<T,U> given(Fact<T>... facts)
public StandardDecision<T,U> given(java.util.List<Fact<T>> facts)
public StandardDecision<T,U> given(FactMap<T> facts)
public StandardDecision<T,U> when(java.util.function.Predicate<FactMap<T>> test)
Predicate that returns true or false based on Facts.public StandardDecision<T,U> 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 StandardDecision<T,U> then(java.util.function.BiFunction<FactMap<T>,Result<U>,RuleState> action)
public void setNextRule(Rule<T> rule)
setNextRule in interface Rule<T>rule - the next Rule to add to the chainpublic U getResult()
public FactMap<T> getFactMap()
public java.util.function.Predicate<FactMap<T>> getWhen()
RulePredicate that evaluates the condition of the Rule.