T - The payload type of the event.@ProviderType
public abstract class PushEvent<T>
extends java.lang.Object
PushEvent.EventType.DATA – Provides access to a typed data element in the
stream.
PushEvent.EventType.CLOSE – The stream is closed. After receiving this
event, no more events will follow.
PushEvent.EventType.ERROR – The stream ran into an unrecoverable problem
and is sending the reason downstream. The stream is closed and no more events
will follow after this event.
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
PushEvent.CloseEvent<T> |
(package private) static class |
PushEvent.DataEvent<T> |
(package private) static class |
PushEvent.ErrorEvent<T> |
static class |
PushEvent.EventType
The type of a
PushEvent. |
| Constructor and Description |
|---|
PushEvent()
Package private default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> PushEvent<T> |
close()
Create a new close event.
|
static <T> PushEvent<T> |
data(T payload)
Create a new data event.
|
static <T> PushEvent<T> |
error(java.lang.Throwable t)
Create a new error event.
|
T |
getData()
Return the data for this event.
|
java.lang.Throwable |
getFailure()
Return the error that terminated the stream.
|
abstract PushEvent.EventType |
getType()
Get the type of this event.
|
boolean |
isTerminal()
Answer if no more events will follow after this event.
|
<X> PushEvent<X> |
nodata()
Convenience to cast a close/error event to another payload type.
|
public abstract PushEvent.EventType getType()
public T getData()
java.lang.IllegalStateException - if this event is not a
PushEvent.EventType.DATA event.public java.lang.Throwable getFailure()
java.lang.IllegalStateException - if this event is not an
PushEvent.EventType.ERROR event.public boolean isTerminal()
false if this is a data event, otherwise true.public static <T> PushEvent<T> data(T payload)
T - The payload type.payload - The payload.public static <T> PushEvent<T> error(java.lang.Throwable t)
T - The payload type.t - The error.public static <T> PushEvent<T> close()
T - The payload type.public <X> PushEvent<X> nodata()
X - The new payload type.java.lang.IllegalStateException - if the event is a PushEvent.EventType.DATA
event.