YARE - Rules Engine in Plain Java

Build Status Maven Central

YARE (Yet Another Rules Engine) is a rule engine written in Java. It is an approach to implement an Expert System which is reliable, fast and full of capabilities.

Why Yet Another Rules Engine?

Beyond the advantages of business rules engines YARE makes its own contribution to user experience:

Getting Started

To start playing with YARE just add the dependency to com.sabre.oss.yare:yare-engine:

Maven

<dependency>
    <groupId>com.sabre.oss.yare</groupId>
    <artifactId>yare-engine</artifactId>
    <version>${yare.version}</version>
</dependency>

Gradle

dependencies {
  compile "com.sabre.oss.yare:yare-engine:$yareVersion"
}

Example

First step towards evaluation using the rule engine is to define a rule.

We can do it using:

As you can see we operate on Flight fact so let's define it too.

public class Flight {
        private String destination;
        private String classOfService;

        // getters and setters
}

Since we are using collect action we have to provide implementation as well.

public class Action {
        public void collect(List<Flight> result, Flight fact) {
            result.add(fact);
        }
}

Last, but certainly not least, we need to create the rules engine itself. Exactly as shown below.

RulesEngine rulesEngine = new RulesEngineBuilder()
                .withRulesRepository((uri) -> Collections.singletonList(rule))
                .withActionMapping("collect", method(new Action(), (action) -> action.collect(null, null)))
                .build()

The only thing left is to evaluate our example.

RuleSession ruleSession = rulesEngine.createSession("ruleSet");
List<Flight> result = ruleSession.execute(new ArrayList(), flights);

For more information about how to use YARE please read YARE User's Guide and check yare-examples module.

Contributing

We accept pull request via GitHub. Here are some guidelines which will make applying PRs easier for us:

See CONTRIBUTING document for more details.

JDK support policy

YARE supports each LTS (Long Term Support) version of the Java platform starting from the version 1.8. Moreover, it is compatible with every non-LTS version released after the latest LTS.

Each JDK has separate Travis pipeline to ensure proper compatibility. Please make sure your changes don't break any supported version.

Currently YARE supports following JDK versions:

License

Copyright 2018 Sabre GLBL Inc.

Output artifacts are under the MIT license.

Apache License Version 2.0 is utilized for project's tooling only (Maven Wrapper) and is not a part of output artifacts.