Interface ConflictResolver

All Known Implementing Classes:
OrderConflictResolver, PriorityConflictResolver
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ConflictResolver
Conflict Resolver Interface - Determines Rule Execution Order 冲突解决器接口 - 确定规则执行顺序

When multiple rules match, the conflict resolver determines the order in which they should be executed.

当多个规则匹配时,冲突解决器确定它们应该执行的顺序。

Features | 主要功能:

  • Rule ordering - 规则排序
  • Pluggable strategies - 可插拔策略

Usage Examples | 使用示例:

ConflictResolver resolver = rules -> {
    List<Rule> sorted = new ArrayList<>(rules);
    sorted.sort(Comparator.comparingInt(Rule::getPriority));
    return sorted;
};
engine.setConflictResolver(resolver);

Security | 安全性:

  • Thread-safe: Implementation dependent - 线程安全: 取决于实现
  • Null-safe: No (rules list 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 Type
    Method
    Description
    resolve(List<Rule> rules)
    Resolves conflicts by ordering the matching rules 通过对匹配规则排序来解决冲突
  • Method Details

    • resolve

      List<Rule> resolve(List<Rule> rules)
      Resolves conflicts by ordering the matching rules 通过对匹配规则排序来解决冲突
      Parameters:
      rules - the matching rules | 匹配的规则
      Returns:
      ordered list of rules | 排序后的规则列表