com.deliveredtechnologies.rulebook.lang.RuleBookAuditableRuleBuilder 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.lang;
import com.deliveredtechnologies.rulebook.model.AuditableRule;
import com.deliveredtechnologies.rulebook.model.GoldenRule;
import com.deliveredtechnologies.rulebook.model.Rule;
import com.deliveredtechnologies.rulebook.model.RuleBook;
/**
* A chained builder for building a Rule in the context of a RuleBook that can be audited.
*/
public class RuleBookAuditableRuleBuilder {
private RuleBook _ruleBook;
private Class extends Rule> _ruleClass;
private String _ruleName;
RuleBookAuditableRuleBuilder(RuleBook ruleBook, Class extends Rule> ruleClass, String ruleName) {
_ruleBook = ruleBook;
_ruleClass = ruleClass;
_ruleName = ruleName;
}
/**
* Specifies the fact type
* @param factType the type of object that facts are restricted to in the Rule.
* @param the generic fact type
* @return RuleBookRuleWithFactTypeBuilder for building RuleBook Rules with a specific fact type
*/
@SuppressWarnings("unchecked")
public RuleBookRuleWithFactTypeBuilder withFactType(Class factType) {
Rule rule =
new AuditableRule((Rule)RuleBuilder.create(_ruleClass).withFactType(factType).build(), _ruleName);
_ruleBook.addRule(rule);
return new RuleBookRuleWithFactTypeBuilder<>(rule);
}
/**
* Specifies no fact type.
* A generic Object type is used for the Rule's fact type.
* @return RuleBookRuleWithFactTypeBuilder for building RuleBook Rules with a specific fact type
*/
public RuleBookRuleWithFactTypeBuilder
© 2015 - 2025 Weber Informatics LLC | Privacy Policy