Record Class RuleTrace

java.lang.Object
java.lang.Record
cloud.opencode.base.rules.trace.RuleTrace
Record Components:
ruleName - the rule name | 规则名称
conditionResult - whether condition evaluated to true | 条件是否评估为true
executed - whether action was executed | 动作是否已执行
duration - evaluation + execution time | 评估和执行时间
error - null if no error | 如果没有错误则为null
skipped - true if rule was disabled/skipped | 如果规则被禁用/跳过则为true

public record RuleTrace(String ruleName, boolean conditionResult, boolean executed, Duration duration, Throwable error, boolean skipped) extends Record
Rule Trace - Records the Execution Trace of a Single Rule 规则轨迹 - 记录单个规则的执行轨迹

Captures whether a rule's condition matched, whether its action was executed, the duration of evaluation and execution, and any error that occurred.

捕获规则条件是否匹配、动作是否执行、评估和执行的持续时间以及发生的任何错误。

Since:
JDK 25, opencode-base-rules V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    RuleTrace(String ruleName, boolean conditionResult, boolean executed, Duration duration, Throwable error, boolean skipped)
    Canonical constructor with validation 带验证的规范构造函数
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns the value of the conditionResult record component.
    Returns the value of the duration record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the error record component.
    boolean
    Returns the value of the executed record component.
    static RuleTrace
    failed(String name, Duration duration, Throwable error)
    Creates a trace for a rule that failed during execution 创建执行期间失败的规则轨迹
    static RuleTrace
    fired(String name, Duration duration)
    Creates a trace for a rule that fired (condition matched and action executed) 创建已触发规则的轨迹(条件匹配且动作已执行)
    boolean
    Returns whether this rule failed during execution 返回此规则在执行期间是否失败
    boolean
    Returns whether this rule fired (condition matched and action executed) 返回此规则是否已触发(条件匹配且动作已执行)
    final int
    Returns a hash code value for this object.
    static RuleTrace
    notMatched(String name, Duration duration)
    Creates a trace for a rule whose condition did not match 创建条件不匹配的规则轨迹
    Returns the value of the ruleName record component.
    boolean
    Returns the value of the skipped record component.
    static RuleTrace
    Creates a trace for a rule that was skipped (disabled) 创建被跳过(禁用)的规则轨迹
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RuleTrace

      public RuleTrace(String ruleName, boolean conditionResult, boolean executed, Duration duration, Throwable error, boolean skipped)
      Canonical constructor with validation 带验证的规范构造函数
      Parameters:
      ruleName - the rule name | 规则名称
      conditionResult - whether condition evaluated to true | 条件是否评估为true
      executed - whether action was executed | 动作是否已执行
      duration - evaluation + execution time | 评估和执行时间
      error - null if no error | 如果没有错误则为null
      skipped - true if rule was disabled/skipped | 如果规则被禁用/跳过则为true
  • Method Details

    • fired

      public static RuleTrace fired(String name, Duration duration)
      Creates a trace for a rule that fired (condition matched and action executed) 创建已触发规则的轨迹(条件匹配且动作已执行)
      Parameters:
      name - the rule name | 规则名称
      duration - the evaluation + execution duration | 评估和执行持续时间
      Returns:
      the rule trace | 规则轨迹
    • notMatched

      public static RuleTrace notMatched(String name, Duration duration)
      Creates a trace for a rule whose condition did not match 创建条件不匹配的规则轨迹
      Parameters:
      name - the rule name | 规则名称
      duration - the evaluation duration | 评估持续时间
      Returns:
      the rule trace | 规则轨迹
    • skipped

      public static RuleTrace skipped(String name)
      Creates a trace for a rule that was skipped (disabled) 创建被跳过(禁用)的规则轨迹
      Parameters:
      name - the rule name | 规则名称
      Returns:
      the rule trace | 规则轨迹
    • failed

      public static RuleTrace failed(String name, Duration duration, Throwable error)
      Creates a trace for a rule that failed during execution 创建执行期间失败的规则轨迹
      Parameters:
      name - the rule name | 规则名称
      duration - the evaluation + execution duration | 评估和执行持续时间
      error - the error that occurred | 发生的错误
      Returns:
      the rule trace | 规则轨迹
    • hasFired

      public boolean hasFired()
      Returns whether this rule fired (condition matched and action executed) 返回此规则是否已触发(条件匹配且动作已执行)
      Returns:
      true if the rule fired | 如果规则已触发返回true
    • hasFailed

      public boolean hasFailed()
      Returns whether this rule failed during execution 返回此规则在执行期间是否失败
      Returns:
      true if the rule failed | 如果规则失败返回true
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • ruleName

      public String ruleName()
      Returns the value of the ruleName record component.
      Returns:
      the value of the ruleName record component
    • conditionResult

      public boolean conditionResult()
      Returns the value of the conditionResult record component.
      Returns:
      the value of the conditionResult record component
    • executed

      public boolean executed()
      Returns the value of the executed record component.
      Returns:
      the value of the executed record component
    • duration

      public Duration duration()
      Returns the value of the duration record component.
      Returns:
      the value of the duration record component
    • error

      public Throwable error()
      Returns the value of the error record component.
      Returns:
      the value of the error record component
    • skipped

      public boolean skipped()
      Returns the value of the skipped record component.
      Returns:
      the value of the skipped record component