-
Notifications
You must be signed in to change notification settings - Fork 5
DSL Description Dutch
A description of the many features of the Rule Engine DSL. This page explains the Dutch DSL. Apart from the DSL terms, it is written in English.
###Basic setup A calculation follows a pre-defined pre-defined structure.
Gegeven (Condition) Bereken Fact is (Evaluation)
It starts with the word Gegeven
followed by a DslCondition (explained below) between brackets. Next is the word Bereken
which is followed by the outputFact of the calculation. Facts are usually defined in a Glossary. Brackets are not needed here. Finally there is the is
word, after which comes either an DslEvaluation or a Subberekening. Brackets are often, but not always, needed. It is advised to always use them, to not run into any problems.
It is possible to chain several calculations that share the same Condition. Do this uses the en
word after the evaluation.
Gegeven (...) Bereken ... is (...) en
... is (...)
Calculations have to be inside a Berekening
class. The easiest way to do this is to create a class of your own:
class MyBerekening extends Berekening (
Gegeven (...) Bereken ... is (...)
,
Gegeven (...) Bereken ... is (...)
)
After the Gegeven
word you have to define a DslCondition. This condition will determine whether the calculation will trigger and the resulting Fact calculated1. A DslCondition starts with a Fact followed by a conditional operator and another Fact or a constant value. Conditions can be chained using en
or of
. These combinations will be evaluated from left to right. When combining en
and of
, it is best to use brackets to group conditions. These will be respected when evaluating and grouping behaves like expected from mathematics.
Some examples of Conditions:
Gegeven (Fact1 is Fact2 of Fact1 > 0)
Gegeven (Fact1 is true of (Fact2 >= 0 en Fact3 <= 5))
Because it is mandatory to start with a condition, there is a special condition that will always evaluate to true. This ensures that the calculation is executed without any extra condition. This special condition can be used by using the word altijd
as seen here
Gegeven (altijd)
##The Evaluation
An evaluation is used to assign a value to the Fact defined as output (the fact given after the Bereken
) After the is
word you have to define a DslEvaluation or a SubCalculation.
###DslEvaluation
1: The Dsl does not only look to the Condition to see if a rule can trigger. The Dsl also ensures that the (Input)Facts needed to calculate the outcome are added as a condition to the Engine. See the Evaluation section for more details