Package org.springframework.http.codec
Interface ServerSentEvent.Builder<T>
- Type Parameters:
T
- the type of data that this event contains
- Enclosing class:
- ServerSentEvent<T>
public static interface ServerSentEvent.Builder<T>
A mutable builder for aSseEvent
.
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ServerSentEvent<T>
build()
Builds the event.ServerSentEvent.Builder<T>
comment(String comment)
Set SSE comment.ServerSentEvent.Builder<T>
data(T data)
Set the value of thedata
field.ServerSentEvent.Builder<T>
event(String event)
Set the value of theevent
field.ServerSentEvent.Builder<T>
id(String id)
Set the value of theid
field.ServerSentEvent.Builder<T>
retry(Duration retry)
Set the value of theretry
field.
Method Detail
id
ServerSentEvent.Builder<T> id(String id)
Set the value of theid
field.- Parameters:
id
- the value of the id field- Returns:
this
builder
event
ServerSentEvent.Builder<T> event(String event)
Set the value of theevent
field.- Parameters:
event
- the value of the event field- Returns:
this
builder
retry
ServerSentEvent.Builder<T> retry(Duration retry)
Set the value of theretry
field.- Parameters:
retry
- the value of the retry field- Returns:
this
builder
comment
ServerSentEvent.Builder<T> comment(String comment)
Set SSE comment. If a multi-line comment is provided, it will be turned into multiple SSE comment lines as defined in Server-Sent Events W3C recommendation.- Parameters:
comment
- the comment to set- Returns:
this
builder
data
ServerSentEvent.Builder<T> data(@Nullable T data)
Set the value of thedata
field. If thedata
argument is a multi-lineString
, it will be turned into multipledata
field lines as defined in the Server-Sent Events W3C recommendation. Ifdata
is not a String, it will be encoded into JSON.- Parameters:
data
- the value of the data field- Returns:
this
builder
build
ServerSentEvent<T> build()
Builds the event.- Returns:
- the built event