public static class OutboundEvent.Builder extends Object implements OutboundSseEvent.Builder
OutboundEvent instances.| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
OutboundEvent |
build()
Build
OutboundEvent. |
OutboundEvent.Builder |
comment(String comment)
Set comment string associated with the event.
|
OutboundEvent.Builder |
data(Class type,
Object data)
Set event data and java type of event data.
|
OutboundEvent.Builder |
data(GenericType type,
Object data)
Set event data and a generic java type of event data.
|
OutboundEvent.Builder |
data(Object data)
Set event data and java type of event data.
|
OutboundEvent.Builder |
id(String id)
Set event id.
|
OutboundEvent.Builder |
mediaType(MediaType mediaType)
Set the
media type of the event data. |
OutboundEvent.Builder |
name(String name)
Set event name.
|
OutboundEvent.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 OutboundEvent.Builder name(String name)
Will be send as a value of the SSE "event" field. This field is optional.
name in interface OutboundSseEvent.Buildername - event name.public OutboundEvent.Builder id(String id)
Will be send as a value of the SSE "id" field. This field is optional.
id in interface OutboundSseEvent.Builderid - event id.public OutboundEvent.Builder reconnectDelay(long milliseconds)
Will be send as a value of the SSE "retry" field. This field is optional.
Absence of a value of this field in an OutboundEvent instance
is indicated by SseFeature.RECONNECT_NOT_SET value returned from
OutboundEvent.getReconnectDelay().
reconnectDelay in interface OutboundSseEvent.Buildermilliseconds - reconnection delay in milliseconds. Negative values un-set the reconnection delay.public OutboundEvent.Builder mediaType(MediaType mediaType)
media type of the event data.
This information is mandatory. The default value is MediaType.TEXT_PLAIN.
mediaType in interface OutboundSseEvent.BuildermediaType - MediaType of event data. Must not be null.NullPointerException - in case the mediaType parameter is null.public OutboundEvent.Builder comment(String comment)
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.Buildercomment - comment string.public OutboundEvent.Builder data(Class type, Object data)
MessageBodyWriter lookup.
Note that multiple invocations of this method result in previous even data being replaced with new one.
data in interface OutboundSseEvent.Buildertype - java type of supplied data. Must not be null.data - event data. Must not be null.NullPointerException - in case either type or data parameter is null.public OutboundEvent.Builder data(GenericType type, Object data)
MessageBodyWriter lookup.
Note that multiple invocations of this method result in previous even data being replaced with new one.
data in interface OutboundSseEvent.Buildertype - generic type of supplied data. Must not be null.data - event data. Must not be null.NullPointerException - in case either type or data parameter is null.public OutboundEvent.Builder data(Object data)
GenericEntity.
Note that multiple invocations of this method result in previous even data being replaced with new one.
data in interface OutboundSseEvent.Builderdata - event data. Must not be null.NullPointerException - in case the data parameter is null.public OutboundEvent build()
OutboundEvent.
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.BuilderOutboundEvent instance.IllegalStateException - when called with invalid configuration (neither a comment nor event data are set).Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.