@aljunggren aljunggren authored on 31 Jan 2021
src Changed abstract classes to interfaces. 5 years ago
.gitignore Initial commit 5 years ago
README.md Updated readme 5 years ago
lombok.config Initial commit 5 years ago
pom.xml Initial commit 5 years ago
README.md

Rules Engine

Engine

Engine<I, O> engine = new Engine<>(codex);

Codex - Set of rules

Codex<I, O> codex = new Codex<>();

ConflictResolution - Interace for conflict resolution

public interface ConflictResolution<I, O> {
    O resolve(List<Rule<I, O>> rules, I input);
}

Rule - Interface for rules

public interface Rule<I, O> {
    boolean applies(I input); 
    O execute(I input);
}

Codex

Codex contains three private members.

    List<Rule<I, O>> rules;
    Rule<I, O> defaultRule;
    ConflictResolution<I, O> conflictResolution;
  • rules - The set of rules that are iterated through by the Engine.
  • defaultRule - Optional rule that will be triggered if no other rules are applicable.
  • conflictResolution - Optional code triggered when multiple rules are applicable.