RuleEngine class
Represents a JSON based rule engine where all rules are stored in JSON format.
The rule engine is responsible for executing rules based on the context provided. It evaluates the conditions of each rule and if the conditions are met, it executes the action associated with the rule. All rules are stored in a rule repository and are executed in descending order of priority.
The facts are passed to the rule engine via RuleContext and is used to
evaluate the conditions and execute the actions. The facts can be passed as
a map of key-value pairs where the keys are strings and the values are dynamic
including user-defined objects. To access the fields of a user-defined object,
one must provide the list of MemberAccessor
s to the resolve
parameter of
the RuleContext which are used to access the fields of the object.
The rule engine can be configured with custom actions and conditions. It also supports event listeners that can be used to listen to rule activations.
The rule engine is asynchronous and can be used in a non-blocking manner.
Constructors
- RuleEngine.new(RuleRepository _ruleRepository)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addListener(
ActivationEventListener listener) → void - Adds an event listener to the rule engine.
-
dispose(
) → Future< void> - Disposes the rule engine.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerAction(
Action action) → void - Registers a custom action with the rule engine.
-
registerCondition(
Condition condition) → void - Registers a custom condition with the rule engine.
-
removeListener(
ActivationEventListener listener) → void - Removes an event listener from the rule engine.
-
run(
RuleContext context) → Future< void> - Runs the rule engine with the given context.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator +(
ActivationEventListener listener) → void - Adds an event listener to the rule engine.
-
operator -(
ActivationEventListener listener) → void - Removes an event listener from the rule engine.
-
operator ==(
Object other) → bool -
The equality operator.
inherited