public abstract class RuleBook<T>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<Fact<T>> |
_facts |
protected java.util.Optional<Rule<T>> |
_headRule |
protected Rule<T> |
_tailRule |
| Constructor and Description |
|---|
RuleBook() |
| Modifier and Type | Method and Description |
|---|---|
void |
addRule(Rule<T> rule)
The addRule() method adds a rule to the end of the Rules chain.
|
protected abstract void |
defineRules()
this is where the rules can be specified in the subclass; it will be executed by run().
|
RuleBook<T> |
given(Fact<T>... facts)
The given() method accepts the Facts for this RuleBook.
|
void |
run()
The run() method adds the rules [via defineRules()] and runs the rules as long as at least one rule was
added.
|
public final void run()
@SafeVarargs public final RuleBook<T> given(Fact<T>... facts)
facts - Facts to be added to the RuleBook and applied to all the Rules in the RuleBookpublic void addRule(Rule<T> rule)
rule - the Rule to be addedprotected abstract void defineRules()