javaeasy-rules

Easy-rules: Cannot resolve aNewRulesEngine()


The code below cannot be compiled due to 'cannot find symbol symbol: class aNewRulesEngine location: class org.jeasy.rules.core.RulesEngineBuilder'

However, judging by this tutorial https://github.com/j-easy/easy-rules/wiki/fizz-buzz it should be fine.

Any ideas why does it goes sour?

import org.jeasy.rules.api.RulesEngine;
import org.jeasy.rules.core.RulesEngineBuilder;

public class Main {

    public static void main(String[] args) {
        RulesEngine rulesEngine = new RulesEngineBuilder.aNewRulesEngine();
    }
}

Solution

  • aNewRulesEngine is a static method in RulesEngineBuilder (according to the documentation: https://github.com/j-easy/easy-rules/blob/master/easy-rules-core/src/main/java/org/jeasy/rules/core/RulesEngineBuilder.java) - but in your code sample, you are also trying to instantiate an instance for RulesEngineBuilder.

    Perhaps this code will work better:

    import org.jeasy.rules.api.RulesEngine;
    import org.jeasy.rules.core.RulesEngineBuilder;
    
    public class Main {
    
        public static void main(String[] args) {
            RulesEngine rulesEngine = RulesEngineBuilder.aNewRulesEngine();
        }
    }