A org.jeasy.rules.api.Rule implementation that uses MVEL to evaluate and execute the rule. @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
| 40 | * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) |
| 41 | */ |
| 42 | public class MVELRule extends BasicRule { |
| 43 | |
| 44 | private Condition condition = Condition.FALSE; |
| 45 | private final List<Action> actions = new ArrayList<>(); |
| 46 | private final ParserContext parserContext; |
| 47 | |
| 48 | /** |
| 49 | * Create a new MVEL rule. |
| 50 | */ |
| 51 | public MVELRule() { |
| 52 | this(new ParserContext()); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Create a new MVEL rule. |
| 57 | * |
| 58 | * @param parserContext used to parse condition/action expressions |
| 59 | */ |
| 60 | public MVELRule(ParserContext parserContext) { |
| 61 | super(Rule.DEFAULT_NAME, Rule.DEFAULT_DESCRIPTION, Rule.DEFAULT_PRIORITY); |
| 62 | this.parserContext = parserContext; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Set rule name. |
| 67 | * |
| 68 | * @param name of the rule |
| 69 | * @return this rule |
| 70 | */ |
| 71 | public MVELRule name(String name) { |
| 72 | this.name = name; |
| 73 | return this; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Set rule description. |
| 78 | * |
| 79 | * @param description of the rule |
| 80 | * @return this rule |
| 81 | */ |
| 82 | public MVELRule description(String description) { |
| 83 | this.description = description; |
| 84 | return this; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Set rule priority. |
| 89 | * |
| 90 | * @param priority of the rule |
| 91 | * @return this rule |
| 92 | */ |
| 93 | public MVELRule priority(int priority) { |
| 94 | this.priority = priority; |
| 95 | return this; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Specify the rule's condition as MVEL expression. |
nothing calls this directly
no outgoing calls
no test coverage detected