j-easy / easy-rules

The simple, stupid rules engine for Java
https://github.com/j-easy/easy-rules/wiki
MIT License
4.86k stars 1.05k forks source link

How to Calling Java methods #347

Closed 9odes closed 3 years ago

9odes commented 3 years ago

Hello, I want to call the Java method in actions and how to do it.

daidai21 commented 3 years ago

in README.md https://github.com/j-easy/easy-rules#either-in-a-declarative-way-using-annotations

// java method
public MethodExample {
    public static void callExampleFunction() {
        ....
    }
}

@Rule(name = "example rule", description = "...")
public class ExamplerRule {

    @Condition
    public boolean isCond(@Fact("cond") boolean cond) {
        return cond;
    }

    @Action
    public void doing() {
        // call function
        MethodExample.callExampleFunction();
    }
}
9odes commented 3 years ago

OK,thanks