au.com.agilepractices.rules.engine.examples:rules-engine-examples-hmrc-tax

A simple rules library written in Java

License

License

GroupId

GroupId

au.com.agilepractices.rules.engine.examples
ArtifactId

ArtifactId

rules-engine-examples-hmrc-tax
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

A simple rules library written in Java

Download rules-engine-examples-hmrc-tax

How to add to project

<!-- https://jarcasting.com/artifacts/au.com.agilepractices.rules.engine.examples/rules-engine-examples-hmrc-tax/ -->
<dependency>
    <groupId>au.com.agilepractices.rules.engine.examples</groupId>
    <artifactId>rules-engine-examples-hmrc-tax</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/au.com.agilepractices.rules.engine.examples/rules-engine-examples-hmrc-tax/
implementation 'au.com.agilepractices.rules.engine.examples:rules-engine-examples-hmrc-tax:1.0.2'
// https://jarcasting.com/artifacts/au.com.agilepractices.rules.engine.examples/rules-engine-examples-hmrc-tax/
implementation ("au.com.agilepractices.rules.engine.examples:rules-engine-examples-hmrc-tax:1.0.2")
'au.com.agilepractices.rules.engine.examples:rules-engine-examples-hmrc-tax:jar:1.0.2'
<dependency org="au.com.agilepractices.rules.engine.examples" name="rules-engine-examples-hmrc-tax" rev="1.0.2">
  <artifact name="rules-engine-examples-hmrc-tax" type="jar" />
</dependency>
@Grapes(
@Grab(group='au.com.agilepractices.rules.engine.examples', module='rules-engine-examples-hmrc-tax', version='1.0.2')
)
libraryDependencies += "au.com.agilepractices.rules.engine.examples" % "rules-engine-examples-hmrc-tax" % "1.0.2"
[au.com.agilepractices.rules.engine.examples/rules-engine-examples-hmrc-tax "1.0.2"]

Dependencies

compile (2)

Group / Artifact Type Version
au.com.agilepractices.rules.engine : rules-engine-core jar 1.0.2
org.slf4j : slf4j-api jar

test (4)

Group / Artifact Type Version
junit : junit jar 4.13.1
org.mockito : mockito-core jar 2.23.0
org.assertj : assertj-core jar 3.8.0
org.slf4j : slf4j-simple jar 1.7.5

Project Modules

There are no modules declared in this project.

Getting Started

To start playing with rules just add the dependency to your project: au.com.agilepractices.rules.engine:rule-engine-core:

Maven

<dependency>
    <groupId>au.com.agilepractices.rules.engine</groupId>
    <artifactId>rules-engine-core</artifactId>
    <version>${rules.version}</version>
</dependency>

Gradle

dependencies {
  compile "au.com.agilepractices.rules.engine:rules-engine-core:$rulesVersion"
}

A rule consists of:

  • A Condition - which must evaluate to true or false
  • An Action - which is executed if the Condition evaluates to true
  • An optional alternative Action - which is executed if the Condition evaluates to false

Example

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

We can do it using:

  • Java DSL
final Rule<String, String> rule = RuleBuilder.newRule()
        .when((input, ruleAuditor) -> true)
        .then(context -> context.setResult("Hello " + context.getData()))
        .build();

Then add the Rule to a RuleBook

RuleBook<String, String> ruleBook = RuleBook.newInstance(String.class, String.class)
        .add(rule);

To execute the RuleBook:

String result = new SimpleRuleExecutor<>(ruleBook)
        .execute("World");

assertThat(result).isEqualTo("Hello World");

Versions

Version
1.0.2
1.0.1