[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 558
  • Last Modified:

How to return a primitive or object value from a static method using Drools Rule Engine?

I have a static calculation method (many more methods like this one) like:

public class ShareCalculator{
    public static double calculateDailyDecDivRate(DeclaredDividend pDeclaredDiv,  
             FundProductDeclaredDividend pFundProductDeclaredDividend)throws FMSCalculationException{

             ...... verify many if, then else conditions ,, etc....
             then return the double value

    I plan to utilize Drools Rule Engine ...
    Then my real question is how DO I RETURN THE Primitive or Object value from this method to a calling

    Does my question make sense?
    Most of the examples I saw on Drools mostly deal with Object with getter/setter type !!!
    How to I use a class with static methods to return values?

    Thanks much.
1 Solution
What version of Drools are you using? In 4.0 you can imort your static methods as functions like this:

import function your.package.ShareCalculator.calculateDailyDecDivRate

Then you can use the method as a function using it's name like this:

    eval( true )
    System.out.println( calculateDailyDecDivRate( yourInput) );

Hope this helps...
Forced accept.

EE Admin

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now