Structure of a standard rules file

 

package package-name

imports

globals

functions

queries

rules

 

package

User-defined functions, user-defined queries, etc. under the same package, regardless of whether these functions and queries are in the same rule file, can be used directly in the rules. This is similar to the Java class call in the same package of Java. the same.

 

rule

 

rule "name"
    attributes
when
     LHS
then
      RHS
end
The part between when and then in a rule is the LHS part. In the LHS, it can contain 0~n conditions. If the LHS part is not empty, the engine will automatically add an eval(true) condition. Since the condition always returns true, the rule with an empty LHS always returns true. The LHS part is composed of one or more conditions, which are also called patterns (matching patterns). Multiple patterns can be connected using and or or, and parentheses can also be used to determine the priority of patterns.
[Bind variable name:]Object([field constraint])
 In Drools, there is no connection symbol in the pattern, then and is used as the default connection, so in the LHS part of the rule, the two patterns will only return true if both patterns are satisfied. On the surface, "," is the same as "&&" The meaning of , but it should be noted that "," and "&&" and "||" cannot be mixed, that is to say, in the LHS where "&&" or "||" appear, there cannot be "," connectors appear, and vice versa. Comparison Operators There are twelve types of comparison operators in Drools5, namely: >, >=, <, <=, ==, !=, contains, not contains, memberof, not memberof, matches, not matches
Object(field[Collection/Array] contains value)
Object(fieldName memberOf value[Collection/Array])
Object(fieldName matches "regular expression")
Object(fieldName memberOf value[Collection/Array])
                               

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327018148&siteId=291194637