Skip to content

Getting Started

Clayton Long edited this page Apr 11, 2017 · 9 revisions

This small example shows you how to create a RuleBook with Rules that execute actions based on conditions.

Add the RuleBook Core dependency

For Maven

Add the SNAPSHOT repository

<repository>
  <id>sonatype</id>
  <name>sonatype snapshot repository</name>
  <url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>

Add the dependency

<dependency>
  <groupId>com.deliveredtechnologies</groupId>
  <artifactId>rulebook-core</artifactId>
  <version>0.5-SNAPSHOT</version>
</dependency>

For Gradle

Add the SNAPSHOT repository repositories { mavenCentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots" } }

Add the dependency

compile 'com.deliveredtechnologies:rulebook-core:0.5-SNAPSHOT'

Write a RuleBook using the RuleBook Java DSL

import com.deliveredtechnologies.rulebook.lang.RuleBookBuilder;

public static void main(String args[]) {
  RuleBook<String> petRuleBook = RuleBookBuilder.create().withResultType(String.class)
    .withDefaultResult("You probably lonely; you could use a pet!")
    .addRule(rule -> rule
      .when(facts -> facts.get
}
Clone this wiki locally