1

Drools has functionality for declaring new data types in the rule file itself, instead of doing it in the java file.

But how can we define methods for that data type?

For example, if I declare the following type in the rule file:

declare Address
   number : int
   streetName : String
   city : String
end

How can I add a method to it:

public int doubleNumber()
{
  number = number * 2;
}
Anmol Singh Jaggi
  • 8,376
  • 4
  • 36
  • 77

1 Answers1

2

Getters and setters are provided. You cannot add any methods.

You can write a function with the declared type as an argument.

If this is not sufficient, declare Java types.

laune
  • 31,114
  • 3
  • 29
  • 42