Constructor and Description |
---|
RuleAdapter(java.lang.Object pojoRule)
Adapts a POJO to a the default Rule type (i.e.
|
RuleAdapter(java.lang.Object pojoRule,
Rule rule)
Adapts a POJO to a Rule given a POJO and a Rule.
|
Modifier and Type | Method and Description |
---|---|
void |
addAction(java.util.function.BiConsumer action)
Adds an action to the Rule to be invoked if the condition evaluates to true.
|
void |
addAction(java.util.function.Consumer action)
Adds an action to the Rule to be invoked if the condition evaluates to true.
|
void |
addFactNameFilter(java.lang.String... factNames)
Adds a filter to the facts by name.
|
void |
addFacts(NameValueReferable... facts)
Adds facts to a Rule.
|
void |
addFacts(NameValueReferableMap facts)
Adds facts to a Rule.
|
java.util.List<java.lang.Object> |
getActions()
Gets an ordered list of the actions added to the Rule.
|
java.util.function.Predicate<NameValueReferableMap> |
getCondition()
Gets the condition specified for the Rule.
|
NameValueReferableMap |
getFacts()
Gets the facts maintained in the Rule.
|
java.util.Optional<Result> |
getResult()
Gets the Result of the Rule
|
RuleState |
getRuleState()
Gets the RuleState of the Rule.
|
boolean |
invoke()
Invokes the Rule.
|
void |
setCondition(java.util.function.Predicate condition)
Sets the condition for the Rule
|
void |
setFacts(NameValueReferableMap facts)
Sets the facts for a Rule.
|
void |
setResult(Result result)
Sets the Result of the Rule.
|
void |
setRuleState(RuleState ruleState)
Sets the
RuleState for the Rule; determines whether the rule chain should continue or not. |
public RuleAdapter(java.lang.Object pojoRule, Rule rule) throws java.io.InvalidClassException
pojoRule
- the @Rule annotated POJOrule
- a Rule objectjava.io.InvalidClassException
- if the @Rule annotation is missing from the POJOpublic RuleAdapter(java.lang.Object pojoRule) throws java.io.InvalidClassException
GoldenRule
).pojoRule
- the @Rule annotated POJOjava.io.InvalidClassException
- if the @Rule annotation is missing from the POJOpublic void addFacts(NameValueReferable... facts)
Rule
public void addFacts(NameValueReferableMap facts)
Rule
public void setFacts(NameValueReferableMap facts)
Rule
public void setCondition(java.util.function.Predicate condition) throws java.lang.IllegalStateException
Rule
setCondition
in interface Rule
condition
- the true or false condition implementation for the Rule.java.lang.IllegalStateException
public void setRuleState(RuleState ruleState)
Rule
RuleState
for the Rule; determines whether the rule chain should continue or not.setRuleState
in interface Rule
ruleState
- the new RuleState to be setpublic void addAction(java.util.function.Consumer action)
Rule
public void addAction(java.util.function.BiConsumer action)
Rule
public void addFactNameFilter(java.lang.String... factNames)
Rule
addFactNameFilter
in interface Rule
factNames
- the names of the facts filtered (i.e. to be included)public NameValueReferableMap getFacts()
Rule
public java.util.function.Predicate<NameValueReferableMap> getCondition()
Rule
getCondition
in interface Rule
public RuleState getRuleState()
Rule
getRuleState
in interface Rule
public java.util.List<java.lang.Object> getActions()
Rule
getActions
in interface Rule
public boolean invoke()
Rule
public void setResult(Result result)
Rule