All Projects → j-easy → Easy Rules

j-easy / Easy Rules

Licence: mit
The simple, stupid rules engine for Java

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Easy Rules

Rulette
A pragmatic business rule management system
Stars: ✭ 91 (-97.42%)
Mutual labels:  rule-engine, rules-engine, business-rules
feel
Expression Language for creating and executing business rules in decision table based on DMN 1.1 specification for conformance level 3
Stars: ✭ 76 (-97.84%)
Mutual labels:  expression-language, business-rules
NiFi-Rule-engine-processor
Drools processor for Apache NiFi
Stars: ✭ 34 (-99.03%)
Mutual labels:  rule-engine, rules-engine
Nrules
Rules engine for .NET, based on the Rete matching algorithm, with internal DSL in C#.
Stars: ✭ 1,003 (-71.52%)
Mutual labels:  rule-engine, rules-engine
liteflow
Small but powerful rules engine,轻量强大优雅的规则引擎
Stars: ✭ 1,119 (-68.23%)
Mutual labels:  rule-engine, rules-engine
Json Rules Engine
A rules engine expressed in JSON
Stars: ✭ 1,159 (-67.09%)
Mutual labels:  rule-engine, rules-engine
Node Rules
Node-rules is a light weight forward chaining rule engine written in JavaScript.
Stars: ✭ 481 (-86.34%)
Mutual labels:  rule-engine, rules-engine
powerflows-dmn
Power Flows DMN - Powerful decisions and rules engine
Stars: ✭ 46 (-98.69%)
Mutual labels:  rule-engine, rules-engine
ruledesigner
Rule Designer is the Eclipse-based development environment for ODM developers.
Stars: ✭ 14 (-99.6%)
Mutual labels:  rule-engine, business-rules
rools
A small rule engine for Node.
Stars: ✭ 118 (-96.65%)
Mutual labels:  rule-engine, rules-engine
evrete
Evrete is a lightweight and intuitive Java rule engine.
Stars: ✭ 37 (-98.95%)
Mutual labels:  rule-engine, rules-engine
EngineX
Engine X - 实时AI智能决策引擎、规则引擎、风控引擎、数据流引擎。 通过可视化界面进行规则配置,无需繁琐开发,节约人力,提升效率,实时监控,减少错误率,随时调整; 支持规则集、评分卡、决策树,名单库管理、机器学习模型、三方数据接入、定制化开发等;
Stars: ✭ 369 (-89.52%)
Mutual labels:  rule-engine
Plastic
This project provides encapsulation of things like Domain, Application Rules, Business Rules or Business Logic in Application.
Stars: ✭ 30 (-99.15%)
Mutual labels:  business-rules
naive-rete
Python RETE algorithm
Stars: ✭ 51 (-98.55%)
Mutual labels:  rule-engine
reguloj
Lightweight business rule engine
Stars: ✭ 24 (-99.32%)
Mutual labels:  rule-engine
claire
Continuously Learning Artificial Intelligence Rules Engine (Claire) for Smart Homes
Stars: ✭ 18 (-99.49%)
Mutual labels:  rule-engine
rules
One Framework to build a highly declarative and customizable UI without using templates.
Stars: ✭ 38 (-98.92%)
Mutual labels:  rules-engine
go-el
Expression language(EL) to navigate/manipulate in golang structure data
Stars: ✭ 42 (-98.81%)
Mutual labels:  expression-language
graal
Graal is a Java toolkit for querying knowledge bases within the framework of existential rules, aka Datalog+/-. See Graal's homepage:
Stars: ✭ 38 (-98.92%)
Mutual labels:  rule-engine
SandboxJS
Safe eval runtime
Stars: ✭ 18 (-99.49%)
Mutual labels:  expression-language

Easy Rules
The simple, stupid rules engine for Java™

MIT license Build Status Maven Central Javadoc Project status


Project status

As of December 2020, Easy Rules is in maintenance mode. This means only bug fixes will be addressed from now on. Version 4.1.x is the only supported version. Please consider upgrading to this version at your earliest convenience.

Latest news

  • 06/12/2020: Version 4.1 is out with a new module to support Apache JEXL as an additional supported expression language! You can find all details about other changes in the release notes.

What is Easy Rules?

Easy Rules is a Java rules engine inspired by an article called "Should I use a Rules Engine?" of Martin Fowler in which Martin says:

You can build a simple rules engine yourself. All you need is to create a bunch of objects with conditions and actions, store them in a collection, and run through them to evaluate the conditions and execute the actions.

This is exactly what Easy Rules does, it provides the Rule abstraction to create rules with conditions and actions, and the RulesEngine API that runs through a set of rules to evaluate conditions and execute actions.

Core features

  • Lightweight library and easy to learn API
  • POJO based development with an annotation programming model
  • Useful abstractions to define business rules and apply them easily with Java
  • The ability to create composite rules from primitive ones
  • The ability to define rules using an Expression Language (Like MVEL, SpEL and JEXL)

Example

1. First, define your rule..

Either in a declarative way using annotations:

@Rule(name = "weather rule", description = "if it rains then take an umbrella")
public class WeatherRule {

    @Condition
    public boolean itRains(@Fact("rain") boolean rain) {
        return rain;
    }
    
    @Action
    public void takeAnUmbrella() {
        System.out.println("It rains, take an umbrella!");
    }
}

Or in a programmatic way with a fluent API:

Rule weatherRule = new RuleBuilder()
        .name("weather rule")
        .description("if it rains then take an umbrella")
        .when(facts -> facts.get("rain").equals(true))
        .then(facts -> System.out.println("It rains, take an umbrella!"))
        .build();

Or using an Expression Language:

Rule weatherRule = new MVELRule()
        .name("weather rule")
        .description("if it rains then take an umbrella")
        .when("rain == true")
        .then("System.out.println(\"It rains, take an umbrella!\");");

Or using a rule descriptor:

Like in the following weather-rule.yml example file:

name: "weather rule"
description: "if it rains then take an umbrella"
condition: "rain == true"
actions:
  - "System.out.println(\"It rains, take an umbrella!\");"
MVELRuleFactory ruleFactory = new MVELRuleFactory(new YamlRuleDefinitionReader());
Rule weatherRule = ruleFactory.createRule(new FileReader("weather-rule.yml"));

2. Then, fire it!

public class Test {
    public static void main(String[] args) {
        // define facts
        Facts facts = new Facts();
        facts.put("rain", true);

        // define rules
        Rule weatherRule = ...
        Rules rules = new Rules();
        rules.register(weatherRule);

        // fire rules on known facts
        RulesEngine rulesEngine = new DefaultRulesEngine();
        rulesEngine.fire(rules, facts);
    }
}

This is the hello world of Easy Rules. You can find other examples like the Shop, Airco or WebApp tutorials in the wiki.

Contribution

You are welcome to contribute to the project with pull requests on GitHub. Please note that Easy Rules is in maintenance mode, which means only pull requests for bug fixes will be considered.

If you believe you found a bug or have any question, please use the issue tracker.

Awesome contributors

Thank you all for your contributions!

Easy Rules in other languages

Who is using Easy Rules?

Credits

YourKit Java Profiler

Many thanks to YourKit, LLC for providing a free license of YourKit Java Profiler to support the development of Easy Rules.

License

Easy Rules is released under the terms of the MIT license:

The MIT License (MIT)

Copyright (c) 2021 Mahmoud Ben Hassine ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].