In addition to supporting files in drl format, Drools also supports files in xls format (i.e. Excel files). This xls format file is usually called a decision table.
A decision table is a "precise and compact" way to express conditional logic, which is very suitable for business-level rules. Decision tables can be seamlessly replaced with existing drl files. Prools provides the corresponding API to compile xls files into drl format strings.
For example:
decision table syntax:
Keywords | illustrate | Is it necessary |
---|---|---|
RuleSet | Equivalent to package in drl file | Required, there can only be one. If the value corresponding to RuleSet is not set, the default rule_table will be used. |
Sequential | The value is of Boolean type. true means the rules are executed in order from top to bottom in the table, false means out of order | Optional |
Import | Equivalent to import in the drl file. If multiple classes are introduced, the classes are separated by commas. | Optional |
Variables | Equivalent to global in the drl file, used to define global variables. If there are multiple global variables, separate them with commas. | Optional |
RuleTable | It indicates that there will be a batch of rules later, and the name of the RuleTable will be used as the prefix for generating rules in the future. | must |
CONDITION | Rule condition keyword, equivalent to when in drl file. The following two lines represent the LHS part, and the third line is the comment line, which is not counted as the rule part. Starting from the fourth line, each line represents a rule. | Each rule table has at least one |
ACTION | Rule result keyword, equivalent to then in the drl file | Each rule table has at least one |
NO-LOOP | Equivalent to no-loop in drl file | Optional |
AGENDA-GROUP | Equivalent to agenda-group in drl file | Optional |
I will give examples later~