Record Class EventRecord
java.lang.Object
java.lang.Record
cloud.opencode.base.event.store.EventRecord
- Record Components:
id- the unique event ID | 唯一事件IDevent- the event object | 事件对象eventType- the event type class name | 事件类型类名timestamp- the event timestamp | 事件时间戳source- the event source | 事件来源storedAt- the storage timestamp | 存储时间戳sequenceNumber- the sequence number | 序列号
public record EventRecord(String id, Event event, String eventType, Instant timestamp, String source, Instant storedAt, long sequenceNumber)
extends Record
Event Record
事件记录
Immutable record representing a stored event with metadata.
表示带有元数据的已存储事件的不可变记录。
Fields | 字段:
- id - Event unique identifier | 事件唯一标识符
- event - The actual event object | 实际事件对象
- eventType - Event class name | 事件类名
- timestamp - Event timestamp | 事件时间戳
- source - Event source | 事件来源
- storedAt - Storage timestamp | 存储时间戳
- sequenceNumber - Sequence number for ordering | 用于排序的序列号
Usage Examples | 使用示例:
EventRecord record = new EventRecord(
event.getId(),
event,
event.getClass().getName(),
event.getTimestamp(),
event.getSource(),
Instant.now(),
sequenceGenerator.next()
);
Features | 主要功能:
- Core functionality - 核心功能
Security | 安全性:
- Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
- Since:
- JDK 25, opencode-base-event V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.event()Returns the value of theeventrecord component.Returns the value of theeventTyperecord component.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.booleanCheck if the event is of a specific type 检查事件是否为特定类型booleanisWithinTimeRange(Instant from, Instant to) Check if the event is within a time range 检查事件是否在时间范围内static EventRecordCreate event record from an event 从事件创建事件记录longReturns the value of thesequenceNumberrecord component.source()Returns the value of thesourcerecord component.storedAt()Returns the value of thestoredAtrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
EventRecord
public EventRecord(String id, Event event, String eventType, Instant timestamp, String source, Instant storedAt, long sequenceNumber) Creates an instance of aEventRecordrecord class.- Parameters:
id- the value for theidrecord componentevent- the value for theeventrecord componenteventType- the value for theeventTyperecord componenttimestamp- the value for thetimestamprecord componentsource- the value for thesourcerecord componentstoredAt- the value for thestoredAtrecord componentsequenceNumber- the value for thesequenceNumberrecord component
-
-
Method Details
-
of
Create event record from an event 从事件创建事件记录- Parameters:
event- the event | 事件sequenceNumber- the sequence number | 序列号- Returns:
- new event record | 新的事件记录
-
isType
-
isWithinTimeRange
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
id
-
event
-
eventType
-
timestamp
-
source
-
storedAt
-
sequenceNumber
public long sequenceNumber()Returns the value of thesequenceNumberrecord component.- Returns:
- the value of the
sequenceNumberrecord component
-