Interface StreamEvent<T>
-
- Type Parameters:
T
- the type of data item
public interface StreamEvent<T>
Represents an event emitted by a publisher.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
getItem()
The data, if this event represents an emission of data.long
getRequestAmount()
The request amount, if this event represents a request.int
getSubscriptionId()
The opaque id of the subscription that this event relates to.Throwable
getThrowable()
The error, if this event represents an error.boolean
isCancel()
Whether or not this event represents cancellation of the stream.boolean
isComplete()
Whether or not this event represents the completion of the stream.boolean
isData()
Whether or not this event represents an emission of data.boolean
isError()
Whether or not this event represents an error.boolean
isRequest()
Whether or not this event represents a request for more data.
-
-
-
Method Detail
-
getSubscriptionId
int getSubscriptionId()
The opaque id of the subscription that this event relates to.Events are emitted for each subscription to a publisher. This value can be used for differentiating events from different subscriptions.
The ids are only unique for a context. That is, they are not globally unique. More precise semantics of ids should be specified by methods that emit events.
- Returns:
- an opaque id of the subscription this event belongs to
-
isComplete
boolean isComplete()
Whether or not this event represents the completion of the stream.- Returns:
- whether or not this event represents the completion of the stream
-
isError
boolean isError()
Whether or not this event represents an error.If this method returns
true
,getThrowable()
will return the corresponding exception. If this method returnsfalse
,getThrowable()
will returnnull
.- Returns:
- whether or not this event represents an error
-
isData
boolean isData()
Whether or not this event represents an emission of data.If this method returns
true
,getItem()
will return the corresponding data. If this method returnsfalse
,getItem()
will returnnull
.- Returns:
- whether or not this event represents an error
-
isCancel
boolean isCancel()
Whether or not this event represents cancellation of the stream.- Returns:
- whether or not this event represents cancellation of the stream
-
isRequest
boolean isRequest()
Whether or not this event represents a request for more data.If this method returns
true
,getRequestAmount()
will return the amount requested. If this method returnsfalse
,getRequestAmount()
will return0
.- Returns:
- whether or not this event represents an error
-
getRequestAmount
long getRequestAmount()
The request amount, if this event represents a request.If
isRequest()
returnstrue
, this method will return the corresponding request amount. IfisRequest()
returnsfalse
, this method will return0
.- Returns:
- the request amount if this event represents a request, else
0
-
getThrowable
@Nullable Throwable getThrowable()
The error, if this event represents an error.If
isError()
returnstrue
, this method will return the corresponding exception. IfisError()
returnsfalse
, this method will return null.- Returns:
- the error if this event represents an error, else
null
-
-