Record Class FeatureAuditEvent

java.lang.Object
java.lang.Record
cloud.opencode.base.feature.audit.FeatureAuditEvent
Record Components:
featureKey - the feature key | 功能键
operatorId - the operator ID | 操作者ID
action - the action performed | 执行的操作
oldValue - the old enabled state | 旧的启用状态
newValue - the new enabled state | 新的启用状态
timestamp - the event timestamp | 事件时间戳

Features | 主要功能:

  • Immutable audit event record - 不可变的审计事件记录
  • Captures feature name, action, user, and timestamp - 捕获功能名称、操作、用户和时间戳

Security | 安全性:

  • Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
  • Null-safe: No - 空值安全: 否

public record FeatureAuditEvent(String featureKey, String operatorId, String action, boolean oldValue, boolean newValue, Instant timestamp) extends Record
Feature Audit Event 功能审计事件

Immutable record representing a feature audit event.

表示功能审计事件的不可变记录。

Actions | 操作类型:

  • REGISTER - Feature registration | 功能注册
  • ENABLE - Feature enabled | 功能启用
  • DISABLE - Feature disabled | 功能禁用
  • UPDATE_STRATEGY - Strategy updated | 策略更新
  • DELETE - Feature deleted | 功能删除

Usage Examples | 使用示例:

FeatureAuditEvent event = new FeatureAuditEvent(
    "dark-mode",
    "admin@example.com",
    "ENABLE",
    false,
    true,
    Instant.now()
);

auditLogger.log(event);
Since:
JDK 25, opencode-base-feature V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • FeatureAuditEvent

      public FeatureAuditEvent(String featureKey, String operatorId, String action, boolean oldValue, boolean newValue, Instant timestamp)
      Creates an instance of a FeatureAuditEvent record class.
      Parameters:
      featureKey - the value for the featureKey record component
      operatorId - the value for the operatorId record component
      action - the value for the action record component
      oldValue - the value for the oldValue record component
      newValue - the value for the newValue record component
      timestamp - the value for the timestamp record component
  • Method Details

    • isStateChanged

      public boolean isStateChanged()
      Check if this event represents a state change 检查此事件是否表示状态更改
      Returns:
      true if state changed | 如果状态更改返回true
    • toLogString

      public String toLogString()
      Format as log string 格式化为日志字符串
      Returns:
      formatted log string | 格式化的日志字符串
    • 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.
    • featureKey

      public String featureKey()
      Returns the value of the featureKey record component.
      Returns:
      the value of the featureKey record component
    • operatorId

      public String operatorId()
      Returns the value of the operatorId record component.
      Returns:
      the value of the operatorId record component
    • action

      public String action()
      Returns the value of the action record component.
      Returns:
      the value of the action record component
    • oldValue

      public boolean oldValue()
      Returns the value of the oldValue record component.
      Returns:
      the value of the oldValue record component
    • newValue

      public boolean newValue()
      Returns the value of the newValue record component.
      Returns:
      the value of the newValue record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component