public static class OutboundSseEventImpl.BuilderImpl extends Object implements OutboundSseEvent.Builder
Constructor and Description |
---|
BuilderImpl() |
Modifier and Type | Method and Description |
---|---|
OutboundSseEvent |
build()
Build
OutboundSseEvent . |
OutboundSseEvent.Builder |
comment(String comment)
Set comment string associated with the event.
|
OutboundSseEvent.Builder |
data(Class type,
Object data)
Set event data and java type of event data.
|
OutboundSseEvent.Builder |
data(GenericType type,
Object data)
Set event data and a generic java type of event data.
|
OutboundSseEvent.Builder |
data(Object data)
Set event data and java type of event data.
|
OutboundSseEvent.Builder |
id(String id)
Set the event id.
|
OutboundSseEvent.Builder |
mediaType(MediaType mediaType)
Set the
media type of the event data. |
OutboundSseEvent.Builder |
name(String name)
Set event name.
|
OutboundSseEvent.Builder |
reconnectDelay(long milliseconds)
Set reconnection delay (in milliseconds) that indicates how long the event receiver should wait
before attempting to reconnect in case a connection to SSE event source is lost.
|
public OutboundSseEvent.Builder name(String name)
OutboundSseEvent.Builder
Will be send as a value of the SSE "event"
field. This field is optional.
name
in interface OutboundSseEvent.Builder
name
- event name.public OutboundSseEvent.Builder id(String id)
OutboundSseEvent.Builder
Will be send as a value of the SSE "id"
field. This field is optional.
id
in interface OutboundSseEvent.Builder
id
- event id.public OutboundSseEvent.Builder reconnectDelay(long milliseconds)
OutboundSseEvent.Builder
Will be send as a value of the SSE "retry"
field. This field is optional.
Absence of a value of this field in an OutboundSseEvent
instance
is indicated by SseEvent.RECONNECT_NOT_SET
value returned from
SseEvent.getReconnectDelay()
.
reconnectDelay
in interface OutboundSseEvent.Builder
milliseconds
- reconnection delay in milliseconds. Negative values un-set the reconnection delay.public OutboundSseEvent.Builder mediaType(MediaType mediaType)
OutboundSseEvent.Builder
media type
of the event data.
This information is mandatory. The default value is MediaType.TEXT_PLAIN
.
mediaType
in interface OutboundSseEvent.Builder
mediaType
- MediaType
of event data. Must not be null
.public OutboundSseEvent.Builder comment(String comment)
OutboundSseEvent.Builder
The comment will be serialized with the event, before event data are serialized. If the event does not contain any data, a separate "event" that contains only the comment will be sent. This information is optional, provided the event data are set.
Note that multiple invocations of this method result in a previous comment being replaced with a new one. To achieve multi-line comments, a multi-line comment string has to be used.
comment
in interface OutboundSseEvent.Builder
comment
- comment string.public OutboundSseEvent.Builder data(Class type, Object data)
OutboundSseEvent.Builder
Type information will be used for MessageBodyWriter
lookup.
Note that multiple invocations of this method result in previous even data being replaced with new one.
data
in interface OutboundSseEvent.Builder
type
- java type of supplied data. Must not be null
.data
- event data. Must not be null
.public OutboundSseEvent.Builder data(GenericType type, Object data)
OutboundSseEvent.Builder
Type information will be used for MessageBodyWriter
lookup.
Note that multiple invocations of this method result in previous even data being replaced with new one.
data
in interface OutboundSseEvent.Builder
type
- generic type of supplied data. Must not be null
.data
- event data. Must not be null
.public OutboundSseEvent.Builder data(Object data)
OutboundSseEvent.Builder
This is a convenience method that derives the event data type information from the runtime type of
the event data. The supplied event data may be represented as GenericEntity
.
Note that multiple invocations of this method result in previous even data being replaced with new one.
data
in interface OutboundSseEvent.Builder
data
- event data. Must not be null
.public OutboundSseEvent build()
OutboundSseEvent.Builder
OutboundSseEvent
.
There are two valid configurations:
comment
is set, all other parameters are optional.
If event data
and media type
is set,
event data will be serialized after the comment.comment
is not set, at least the event
data
must be set. All other parameters are optional.build
in interface OutboundSseEvent.Builder
OutboundSseEvent
instance.Copyright © 2021 JBoss by Red Hat. All rights reserved.