Record Class SseEvent
java.lang.Object
java.lang.Record
cloud.opencode.base.web.sse.SseEvent
- Record Components:
id- the event ID (optional) - 事件 ID(可选)event- the event type (default: "message") - 事件类型(默认:"message")data- the event data - 事件数据retry- the reconnection time in milliseconds (optional) - 重连时间(毫秒,可选)
SSE Event - Represents a Server-Sent Event
SSE 事件 - 表示服务器发送的事件
Server-Sent Events (SSE) is a technology for pushing events from server to client over HTTP.
服务器发送事件(SSE)是一种通过 HTTP 从服务器向客户端推送事件的技术。
Features | 主要功能:
- Immutable SSE event record - 不可变SSE事件记录
- Builder pattern for event construction - 构建器模式
- Optional fields (id, retry) - 可选字段(id、retry)
Usage Examples | 使用示例:
SseEvent event = SseEvent.of("Hello, World!");
SseEvent typed = SseEvent.of("update", jsonData);
SseEvent full = SseEvent.builder()
.id("123").event("update").data(json).retry(3000).build();
Security | 安全性:
- Thread-safe: Yes (immutable record) - 是(不可变记录)
- Null-safe: Partial (data can be null) - 部分(数据可以为null)
- Since:
- JDK 25, opencode-base-web 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 TypeMethodDescriptionstatic SseEvent.Builderbuilder()data()Returns the value of thedatarecord component.final booleanIndicates whether some other object is "equal to" this one.event()Returns the value of theeventrecord component.getId()getRetry()booleanhasData()final inthashCode()Returns a hash code value for this object.booleanhasId()id()Returns the value of theidrecord component.booleanstatic SseEventstatic SseEventstatic SseEventretry()Returns the value of theretryrecord component.toString()Returns a string representation of this record class.
-
Field Details
-
DEFAULT_EVENT
- See Also:
-
-
Constructor Details
-
SseEvent
-
-
Method Details
-
of
-
of
-
of
-
builder
-
eventOrDefault
-
getId
-
getRetry
-
isMessage
public boolean isMessage() -
hasData
public boolean hasData() -
hasId
public boolean hasId() -
toDebugString
-
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). -
id
-
event
-
data
-
retry
-