I am new to Drools. I am creating a rule but I get a compile time error
"field is not visible'.
I've tried to check with Jboss examples, where they use dialect "mvel". It compiled. I didn't understand about dialect. So what is dialect=mvel
?
DRL (Drools Rule Language) rules are business rules that you define directly in . drl text files. These DRL files are the source in which all other rule assets in Business Central are ultimately rendered.
mvel
, or the MVFLEX Expression Language has a rich syntax, many of which allow for more concise and expressive code (and less imperative) than java
, e.g.
get()
ters / set()
ters (e.g. encapsulating private fields) to be accessed in an alternative property
style syntax (similar to VB or C# properties in .Net)ie. instead of
myObject.setSomeField("SomeValue");
int x = myObject.getSomeIntField();
You can use the syntax (note the subtle capitalization switch as well):
myObject.someField = "SomeValue"
x = myObject.someIntField // Type inferrence
return
statement is optional (a convention found in many functional languages like Scala), as is the semi-colon, unless you have multiple statements per line:x // i.e. return x;
foos = {2, 4, 6, 8, 10}
foos[3] // foos.get(3)
bars = ["a" : "Apple", "b" : "Basket"] // Hashmap, with put
bars["a"]
bars.a // Similar to dynamically typed object e.g. in javascript, if key is a string.
foo.?bar.baz // if (foo.bar != null) { return foo.bar.baz; } else { return null; }
Based on
Drools JBoss Rules 5.0 Developer's Guide
Dialect is used to specify the syntax in any code expression that is in a condition or consequence. The default value is Java. Drools currently supports one more dialect called mvel.
Specifically mvel is an expression language for Java-based applications. And it's based on Java syntax. more info about mvel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With