Drools syntactic sugar
Drools provides all sorts of special syntactic features. As much as we'd like, all of them won't fit in this book and more features are added constantly. Some of them, however, come in very handy when having to define our rules in a simple and comprehensive manner. We'll discuss the top three of these extra features, as follows:
Nested accessors for the attributes of our types
Inline casts for attributes of our types
Null-safe operators
Nested accessors
Nested accessors allow us to simplify our conditions when we have to define conditions on nested beans. Using parentheses, it allows us access the nested properties without having to redeclare the path to get to them. Let's see the following example to fully understand it:
OrderLine( item.cost < 30.0, item.salePrice < 25.0 )
In the previous condition, we're filtering order lines that have an item with a cost under 30 and a sale price under 25. We could simplify the expression using nested accessors, as follows:
OrderLine...