Interface DecisionTable
- All Known Implementing Classes:
SimpleDecisionTable
public interface DecisionTable
Decision Table Interface - Table-Based Rule Definition
决策表接口 - 基于表格的规则定义
Provides a tabular way to define business rules with input conditions and output actions.
提供一种以表格方式定义业务规则的方法,包含输入条件和输出动作。
Features | 主要功能:
- Tabular rule definition - 表格式规则定义
- Multiple hit policies - 多种命中策略
- Context-based evaluation - 基于上下文的评估
Usage Examples | 使用示例:
DecisionTable table = OpenRules.decisionTable()
.name("pricing")
.hitPolicy(HitPolicy.FIRST)
.input("customerType", String.class)
.input("amount", Double.class)
.output("discount", Double.class)
.row(new Object[]{"VIP", ">= 1000"}, new Object[]{0.15})
.row(new Object[]{"VIP", "-"}, new Object[]{0.10})
.row(new Object[]{"-", "-"}, new Object[]{0.0})
.build();
DecisionResult result = table.evaluate(context);
Security | 安全性:
- Thread-safe: Implementation dependent - 线程安全: 取决于实现
- Null-safe: No (context/inputs must not be null) - 空值安全: 否(上下文/输入不能为null)
- Since:
- JDK 25, opencode-base-rules V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionevaluate(RuleContext context) Evaluates the decision table against the given context 针对给定上下文评估决策表Evaluates the decision table against the given inputs 针对给定输入评估决策表Gets the hit policy 获取命中策略Gets the input column names 获取输入列名getName()Gets the decision table name 获取决策表名称Gets the output column names 获取输出列名intGets the number of rows in the table 获取表中的行数
-
Method Details
-
getName
-
getHitPolicy
-
evaluate
Evaluates the decision table against the given context 针对给定上下文评估决策表- Parameters:
context- the rule context | 规则上下文- Returns:
- the decision result | 决策结果
-
evaluate
Evaluates the decision table against the given inputs 针对给定输入评估决策表- Parameters:
inputs- the input values | 输入值- Returns:
- the decision result | 决策结果
-
getRowCount
int getRowCount()Gets the number of rows in the table 获取表中的行数- Returns:
- row count | 行数
-
getInputColumns
-
getOutputColumns
-