Record Class AuditEvent
java.lang.Object
java.lang.Record
cloud.opencode.base.log.audit.AuditEvent
public record AuditEvent(String eventId, Instant timestamp, String userId, String action, String target, String targetId, String result, String ip, String userAgent, Map<String,Object> details)
extends Record
Audit Event - Immutable Audit Log Entry
审计事件 - 不可变的审计日志条目
This record represents an audit event containing information about user actions, including who, what, when, where, and result.
此记录表示包含用户操作信息的审计事件,包括谁、什么、何时、何地和结果。
Example | 示例:
AuditEvent event = AuditEvent.builder("USER_LOGIN")
.userId("user123")
.target("system")
.success()
.ip("192.168.1.1")
.detail("browser", "Chrome")
.build();
Features | 主要功能:
- Immutable audit event record - 不可变的审计事件记录
- Builder pattern for flexible construction - 构建器模式,灵活构造
- Auto-generated event ID and timestamp - 自动生成事件 ID 和时间戳
- Defensive copy of details map - 详情映射的防御性拷贝
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Null-safe: No (action must not be null) - 空值安全: 否(操作不能为 null)
- Since:
- JDK 25, opencode-base-log V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaction()Returns the value of theactionrecord component.static AuditEvent.BuilderCreates a builder for the specified action.details()Returns the value of thedetailsrecord component.final booleanIndicates whether some other object is "equal to" this one.eventId()Returns the value of theeventIdrecord component.final inthashCode()Returns a hash code value for this object.ip()Returns the value of theiprecord component.booleanChecks if the event was successful.result()Returns the value of theresultrecord component.target()Returns the value of thetargetrecord component.targetId()Returns the value of thetargetIdrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.Returns the value of theuserAgentrecord component.userId()Returns the value of theuserIdrecord component.
-
Field Details
-
RESULT_SUCCESS
-
RESULT_FAILURE
-
-
Constructor Details
-
AuditEvent
-
-
Method Details
-
builder
Creates a builder for the specified action. 为指定操作创建构建器。- Parameters:
action- the action - 操作- Returns:
- the builder - 构建器
-
isSuccess
public boolean isSuccess()Checks if the event was successful. 检查事件是否成功。- Returns:
- true if successful - 如果成功返回 true
-
toString
-
hashCode
-
equals
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. All components in this record class are compared withObjects::equals(Object,Object). -
eventId
Returns the value of theeventIdrecord component.- Returns:
- the value of the
eventIdrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-
userId
Returns the value of theuserIdrecord component.- Returns:
- the value of the
userIdrecord component
-
action
Returns the value of theactionrecord component.- Returns:
- the value of the
actionrecord component
-
target
Returns the value of thetargetrecord component.- Returns:
- the value of the
targetrecord component
-
targetId
Returns the value of thetargetIdrecord component.- Returns:
- the value of the
targetIdrecord component
-
result
Returns the value of theresultrecord component.- Returns:
- the value of the
resultrecord component
-
ip
Returns the value of theiprecord component.- Returns:
- the value of the
iprecord component
-
userAgent
Returns the value of theuserAgentrecord component.- Returns:
- the value of the
userAgentrecord component
-
details
-