Skip to content

Introduction

rulii is a lightweight, zero-dependency Java library for defining and executing business rules. It follows the Production Rule Model: IF a condition holds, THEN perform an action, OTHERWISE perform another.

  • Zero dependencies. The core jar depends on nothing. Logging, scripting engines and Jakarta EL are optional and only used when present.
  • Java 17 or later.
  • Two ways to write a rule. Functional, from lambdas, or declarative, as an annotated class.
  • Built-in validation. 48 validation rules, each with a builder, ready to use.
  • Rule flows. Compose rules into pipelines with conditionals, loops, async steps and error handling (since 2.0.0).
  • Introspection. Rules describe themselves: expressions, flow structure, categories, tags and source locations (since 2.1.0).
  • Spring integration. Auto-configuration, dependency injection into rules, and rules, rule sets and flows declared in XML, through rulii-spring.
  • Bean Validation. A Jakarta Bean Validation provider that runs the constraints on your beans as rulii rules, through rulii-bean-validation. It is not a certified implementation; the specification coverage page lists every known difference.
  • Business logic that changes often and should live apart from application code
  • Input validation with structured error reporting: violations, error codes, severities
  • Decisions where conditions determine which actions run
  • Anywhere a chain of if/else blocks needs to be testable and composable
import static org.rulii.model.condition.Conditions.condition;
import static org.rulii.model.action.Actions.action;
// IF age >= 18 THEN print "Welcome!"
Rule rule = Rule.builder()
.name("AgeCheck")
.given(condition((Integer age) -> age >= 18))
.then(action(() -> System.out.println("Welcome!")))
.build();
// Run it through a RuleFlow, the recommended entry point
RuleFlow<RuleContext> flow = RuleFlow.builder()
.name("WelcomeFlow")
.run(rule)
.build();
flow.run(age -> 25);
// Output: Welcome!

That is a complete rule. The rest of this documentation covers every feature, from bindings and conditions to rule sets, rule flows and validation.

rulii began in 2019 as ruling-class, a Java rule framework under the same Apache 2.0 licence. In 2024 it was rewritten for Java 17 and released as rulii, with the same idea at its centre: rules as plain Java, kept apart from the rest of the application. Everything since, rule flows, the Spring integration, Bean Validation and the explorer, builds on that. The longer version is on the Why rulii page. Every release since 2019 is listed in the release history.