A Rule implementation that uses SpEL to evaluate and execute the rule. @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
| 43 | * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com) |
| 44 | */ |
| 45 | public class SpELRule extends BasicRule { |
| 46 | |
| 47 | private Condition condition = Condition.FALSE; |
| 48 | private final List<Action> actions = new ArrayList<>(); |
| 49 | private final ParserContext parserContext; |
| 50 | private BeanResolver beanResolver; |
| 51 | |
| 52 | /** |
| 53 | * Create a new SpEL rule. |
| 54 | */ |
| 55 | public SpELRule() { |
| 56 | this(ParserContext.TEMPLATE_EXPRESSION); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Create a new SpEL rule. |
| 61 | * |
| 62 | * @param parserContext used when parsing expressions |
| 63 | */ |
| 64 | public SpELRule(ParserContext parserContext) { |
| 65 | super(Rule.DEFAULT_NAME, Rule.DEFAULT_DESCRIPTION, Rule.DEFAULT_PRIORITY); |
| 66 | this.parserContext = parserContext; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Create a new SpEL rule. |
| 71 | * |
| 72 | * @param beanResolver used to resolve bean references in expressions |
| 73 | */ |
| 74 | public SpELRule(BeanResolver beanResolver) { |
| 75 | super(Rule.DEFAULT_NAME, Rule.DEFAULT_DESCRIPTION, Rule.DEFAULT_PRIORITY); |
| 76 | this.parserContext = ParserContext.TEMPLATE_EXPRESSION; |
| 77 | this.beanResolver = beanResolver; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Create a new SpEL rule. |
| 82 | * |
| 83 | * @param parserContext used when parsing expressions |
| 84 | * @param beanResolver used to resolve bean references in expressions |
| 85 | */ |
| 86 | public SpELRule(ParserContext parserContext, BeanResolver beanResolver) { |
| 87 | super(Rule.DEFAULT_NAME, Rule.DEFAULT_DESCRIPTION, Rule.DEFAULT_PRIORITY); |
| 88 | this.parserContext = parserContext; |
| 89 | this.beanResolver = beanResolver; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Set rule name. |
| 94 | * |
| 95 | * @param name of the rule |
| 96 | * @return this rule |
| 97 | */ |
| 98 | public SpELRule name(String name) { |
| 99 | this.name = name; |
| 100 | return this; |
| 101 | } |
| 102 |
nothing calls this directly
no outgoing calls
no test coverage detected