Interface FactStore
- All Known Implementing Classes:
DefaultFactStore
public interface FactStore
Fact Store Interface - Manages Facts in Rule Context
事实存储接口 - 管理规则上下文中的事实
Provides typed storage and retrieval of fact objects used during rule evaluation.
提供在规则评估期间使用的事实对象的类型化存储和检索。
Features | 主要功能:
- Type-based fact retrieval - 基于类型的事实检索
- Named fact support - 命名事实支持
- Multiple facts of same type - 同类型多个事实
Usage Examples | 使用示例:
FactStore store = new DefaultFactStore();
store.add("customer", customer);
store.add(order);
Optional<Order> order = store.get(Order.class);
Object customer = store.get("customer");
Security | 安全性:
- Thread-safe: Implementation dependent - 线程安全: 取决于实现
- Null-safe: No (names and types 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 TypeMethodDescriptionvoidAdds a fact to the store 向存储添加事实voidAdds a named fact to the store 向存储添加命名事实voidclear()Clears all facts 清除所有事实booleanChecks if a fact of the given type exists 检查给定类型的事实是否存在booleanChecks if a named fact exists 检查命名事实是否存在<T> Optional<T> Gets a fact by type 按类型获取事实Gets a fact by name 按名称获取事实<T> List<T> Gets all facts of a specific type 获取特定类型的所有事实Removes a named fact 移除命名事实<T> List<T> Removes all facts of a specific type 移除特定类型的所有事实intsize()Gets the total number of facts 获取事实总数
-
Method Details
-
add
-
add
-
get
-
get
-
getAll
-
contains
Checks if a named fact exists 检查命名事实是否存在- Parameters:
name- the fact name | 事实名称- Returns:
- true if exists | 如果存在返回true
-
contains
Checks if a fact of the given type exists 检查给定类型的事实是否存在- Parameters:
type- the fact type | 事实类型- Returns:
- true if exists | 如果存在返回true
-
remove
-
removeAll
-
clear
void clear()Clears all facts 清除所有事实 -
size
int size()Gets the total number of facts 获取事实总数- Returns:
- fact count | 事实数量
-