Class CompositeAction

java.lang.Object
cloud.opencode.base.rules.action.CompositeAction
All Implemented Interfaces:
Action

public class CompositeAction extends Object implements Action
Composite Action - Executes Multiple Actions in Sequence 组合动作 - 按顺序执行多个动作

Combines multiple actions into a single action that executes them sequentially.

将多个动作组合成一个按顺序执行的单一动作。

Features | 主要功能:

  • Sequential action execution - 顺序动作执行
  • Error aggregation with suppressed exceptions - 使用抑制异常的错误聚合
  • Factory method support - 工厂方法支持

Usage Examples | 使用示例:

Action combined = new CompositeAction(List.of(
    ctx -> ctx.setResult("step1", "done"),
    ctx -> ctx.setResult("step2", "done")
));

Security | 安全性:

  • Thread-safe: No (not synchronized) - 线程安全: 否(未同步)
  • Null-safe: No (actions must not be null) - 空值安全: 否(动作不能为null)
Since:
JDK 25, opencode-base-rules V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • CompositeAction

      public CompositeAction(List<Action> actions)
      Creates a composite action 创建组合动作
      Parameters:
      actions - the actions to execute | 要执行的动作
  • Method Details

    • execute

      public void execute(RuleContext context)
      Description copied from interface: Action
      Executes this action with the given context 使用给定上下文执行此动作
      Specified by:
      execute in interface Action
      Parameters:
      context - the rule context | 规则上下文
    • getActions

      public List<Action> getActions()
      Gets the actions 获取动作列表
      Returns:
      the actions | 动作列表
    • of

      public static CompositeAction of(Action... actions)
      Creates a composite action from multiple actions 从多个动作创建组合动作
      Parameters:
      actions - the actions | 动作
      Returns:
      the composite action | 组合动作