Platform that I use requires Drools Rule Language (DRL), but for me more convenient thing is to create rules in Java API.
Is there any way to create rules in Java API, and then convert/transfer it to DRL?
Thx for answer.
Rule Definition − It consists of the Rule Name, the condition, and the Consequence. Drools keywords are rule, when, then, and end. In the above example, the rule names are “Hello World” and “GoodBye”. The when part is the condition in both the rules and the then part is the consequence.
Drools is an open-source Business Rules Management Software (BRMS) written in Java that provides users with a variety of features like Business Rule Engine, Web authoring, Rules Management Application, and runtime support for Decision Model and Notation models.
A DRL file can contain one or more rules that define at minimum the rule conditions ( when ) and actions ( then ). The DRL designer in Decision Central provides syntax highlighting for Java, DRL, and XML. All data objects related to a DRL rule must be in the same project package as the DRL rule in Decision Central.
Drools does have a fluent API for building rules as Geoffrey mentioned, but it is not in the public API. You can use and it has been stable for several years now, but you need to be aware that there might be changes over time due to features being added to the engine.
The API is used by the Drools parser itself. Here are some unit tests that you can use as examples:
https://github.com/droolsjbpm/drools/blob/6.3.x/drools-compiler/src/test/java/org/drools/compiler/lang/api/DescrBuilderTest.java#L451-L465
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