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( ...

Get Mastering JBoss Drools 6 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.