com.deliveredtechnologies.rulebook.lang.RuleBookDefaultResultBuilder 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.Auditor;
import com.deliveredtechnologies.rulebook.model.Rule;
import com.deliveredtechnologies.rulebook.model.RuleBook;
import com.deliveredtechnologies.rulebook.model.RuleBookAuditor;
import java.util.function.Consumer;
/**
* Builds the portion of the RuleBook that specifies a default result value.
*/
public class RuleBookDefaultResultBuilder implements TerminatingRuleBookBuilder {
private RuleBook _ruleBook;
public RuleBookDefaultResultBuilder(RuleBook ruleBook) {
this._ruleBook = ruleBook;
}
/**
* Adds a rule to the RuleBook.
* @param consumer functional interface that supplies a RuleBookRuleBuilder for building a Rule
* @return a builder with the added Rule
*/
public RuleBookAddRuleBuilder addRule(Consumer> consumer) {
return new RuleBookAddRuleBuilder<>(_ruleBook, consumer);
}
/**
* Adds a rule to the RuleBook.
* @param rule Rule to be added into the RuleBook
* @param the fact type of the Rule
* @return RuleBookBuilder with the added Rule
*/
public RuleBookAddRuleBuilder addRule(Rule rule) {
return new RuleBookAddRuleBuilder<>(_ruleBook, rule);
}
/**
* Decorates the RuleBook with {@link Auditor} functionality for rules auditing.
* @return a builder that can add rules
*/
public RuleBookAddRuleBuilder asAuditor() {
return new RuleBookAddRuleBuilder<>(new RuleBookAuditor<>(_ruleBook));
}
@Override
public RuleBook build() {
return _ruleBook;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy