Creating new Scala object in Drools right hand side

后端 未结 1 387
一整个雨季
一整个雨季 2021-01-23 13:38

Since I\'m working with Scala immutable objects within Drools, in order to update a fact I would need to create a new object to replace it. I\'ve written a Scala method for the

相关标签:
1条回答
  • 2021-01-23 13:55

    Importing methods from Scala Object types can be problematic in Drools. The simple reason is that static methods do not exist in Scala in contrast with Java. This is because Scala takes a more stricter interpretation of what it means to be a pure object orientated language.

    What this means is that whenever you try to use the Drools import function syntax, it cannot find any static methods to import. As a result, the Drools compiler complains about any references to methods contained in Scala singleton object types.

    A work around for this is to write any classes which are going to be used in your DRLs in Java where you can explicitly define static methods. The Scala compiler will happily compile these along with your Scala classes.

    0 讨论(0)
提交回复
热议问题