- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.1k
 
defining rules engine
        Mahmoud Ben Hassine edited this page May 28, 2017 
        ·
        9 revisions
      
    Easy Rules default engine applies rules according to their natural order (which is priority by default).
To create a rules engine, you can use the static method RulesEngineBuilder.aNewEngineBuilder():
RulesEngine rulesEngine = aNewEngineBuilder().build();You can then fire registered rules as follows:
rulesEngine.fire(rules, facts);Easy Rules engine can be configured with the following parameters:
| Parameter | Type | Required | Default | 
|---|---|---|---|
| rulePriorityThreshold | int | no | MaxInt | 
| skipOnFirstAppliedRule | boolean | no | false | 
| skipOnFirstFailedRule | boolean | no | false | 
| skipOnFirstNonTriggeredRule | boolean | no | false | 
| silentMode | boolean | no | false | 
- The 
skipOnFirstAppliedRuleparameter tells the engine to skip next rules when a rule is applied. - The 
skipOnFirstFailedRuleparameter tells the engine to skip next rules when a rule fails. - The 
skipOnFirstNonTriggeredRuleparameter tells the engine to skip next rules a rule is not triggered. - The 
rulePriorityThresholdparameter tells the engine to skip next rules if priority exceeds the defined threshold. - The 
silentModeallows you to mute all loggers when needed. 
You can specify these parameters through the RulesEngineBuilder API:
RulesEngine rulesEngine = aNewRulesEngine()
    .withRulePriorityThreshold(10)
    .withSkipOnFirstAppliedRule(true)
    .withSkipOnFirstFailedRule(true)
    .withSkipOnFirstNonTriggeredRule(true)
    .withSilentMode(true)
    .build();All parameters are encapsulated in the RulesEngineParameters class. If you want to get parameters from your engine, you can use the following snippet:
RulesEngineParameters parameters = myEngine.getParameters();This allows you to reset the engine parameters after its creation.
Easy Rules is created by Mahmoud Ben Hassine with the help of some awesome contributors
- 
Introduction
 - 
User guide
 - 
Tutorials
 - 
Get involved