com.deliveredtechnologies.rulebook.model.RuleBookAuditor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rulebook-core Show documentation
Show all versions of rulebook-core Show documentation
A simple and intuitive rules abstraction for Java
package com.deliveredtechnologies.rulebook.model;
import com.deliveredtechnologies.rulebook.NameValueReferableMap;
import com.deliveredtechnologies.rulebook.Result;
import java.util.Optional;
/**
* Created by clong on 9/3/17.
*/
public class RuleBookAuditor extends Auditor implements RuleBook {
private RuleBook _ruleBook;
public RuleBookAuditor(RuleBook ruleBook) {
_ruleBook = ruleBook;
}
@Override
public void addRule(Rule rule) {
if (rule instanceof Auditable) {
Auditable auditableRule = (Auditable)rule;
registerRule(auditableRule);
auditableRule.setAuditor(this);
}
_ruleBook.addRule(rule);
}
@Override
public void run(NameValueReferableMap facts) {
if (!hasRules()) {
defineRules();
}
_ruleBook.run(facts);
}
@Override
public void setDefaultResult(T result) {
_ruleBook.setDefaultResult(result);
}
@Override
public Optional> getResult() {
return _ruleBook.getResult();
}
@Override
public boolean hasRules() {
return _ruleBook.hasRules();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy