Class RuleGroup

java.lang.Object
cloud.opencode.base.rules.model.RuleGroup
All Implemented Interfaces:
Comparable<RuleGroup>

public final class RuleGroup extends Object implements Comparable<RuleGroup>
Rule Group - Collection of Related Rules 规则组 - 相关规则的集合

Groups related rules together for organization and selective execution.

将相关规则组织在一起以便组织和选择性执行。

Features | 主要功能:

  • Named grouping - 命名分组
  • Priority ordering - 优先级排序
  • Description support - 描述支持

Usage Examples | 使用示例:

RuleGroup group = RuleGroup.builder("discount-rules")
    .description("Order discount calculation rules")
    .priority(1)
    .addRule(vipRule)
    .addRule(bulkRule)
    .build();

Security | 安全性:

  • Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
  • Null-safe: No (name must not be null) - 空值安全: 否(名称不能为null)
Since:
JDK 25, opencode-base-rules V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • getName

      public String getName()
      Gets the group name 获取组名
      Returns:
      the group name | 组名
    • getDescription

      public String getDescription()
      Gets the group description 获取组描述
      Returns:
      the description | 描述
    • getPriority

      public int getPriority()
      Gets the group priority 获取组优先级
      Returns:
      the priority | 优先级
    • getRules

      public List<Rule> getRules()
      Gets the rules in this group 获取此组中的规则
      Returns:
      immutable list of rules | 不可变的规则列表
    • size

      public int size()
      Gets the count of rules in this group 获取此组中的规则数量
      Returns:
      rule count | 规则数量
    • isEmpty

      public boolean isEmpty()
      Checks if this group is empty 检查此组是否为空
      Returns:
      true if empty | 如果为空返回true
    • compareTo

      public int compareTo(RuleGroup other)
      Specified by:
      compareTo in interface Comparable<RuleGroup>
    • builder

      public static RuleGroup.Builder builder(String name)
      Creates a builder for RuleGroup 创建RuleGroup的构建器
      Parameters:
      name - the group name | 组名
      Returns:
      the builder | 构建器