1.8 KiB
layout | title | header | prev_section | next_section | doc |
---|---|---|---|---|---|
docs | Rules engine | Rules engine | user-guide/defining-rules | user-guide/managing-rules | true |
Easy Rules engine handles a registry of rules with unique names. Each instance of Easy Rules engine can be seen as a separate namespace.
Rules are applied according to their natural order.
Easy Rules engine provides the following parameters:
Parameter | Type | Required | Default |
---|---|---|---|
skipOnFirstAppliedRule | boolean | no | false |
rulePriorityThreshold | int | no | Integer.MAX_VALUE |
The skipOnFirstAppliedRule
parameter tells the engine to skip next applicable rules when a rule is applied.
The rulePriorityThreshold
parameters tells the engine to skip next rules if priority exceeds the defined threshold.
You can specify these parameters at rules engine construction time.
Create a default rules engine
To create a default Easy Rules engine and register a rule, use the following snippet:
RulesEngine<Rule> rulesEngine = new DefaultRulesEngine();
rulesEngine.registerRule(myRule);
You can fire registered rules as follows:
rulesEngine.fireRules();
Create a annotated rules engine
If your rules are annotated POJOs, you have to use the AnnotatedRulesEngine
to register them:
AnnotatedRulesEngine rulesEngine = new AnnotatedRulesEngine();
rulesEngine.registerRule(myRule);
As with default engine, you can fire rules using the following snippet :
rulesEngine.fireRules();