T
- public final class NotificationLite<T>
extends java.lang.Object
Notification
objects for every onNext
and
onCompleted
.
An object is allocated inside error(Throwable)
to wrap the Throwable
but this shouldn't
affect performance because exceptions should be exceptionally rare.
It's implemented as a singleton to maintain some semblance of type safety that is completely non-existent.
Modifier and Type | Method and Description |
---|---|
boolean |
accept(Observer<? super T> o,
java.lang.Object n)
Unwraps the lite notification and calls the appropriate method on the
Observer . |
java.lang.Object |
completed()
Creates a lite
onCompleted notification without doing any allocation. |
java.lang.Object |
error(java.lang.Throwable e)
Create a lite
onError notification. |
java.lang.Throwable |
getError(java.lang.Object n)
Returns the
Throwable corresponding to this OnError lite notification. |
T |
getValue(java.lang.Object n)
Returns the item corresponding to this
OnNext lite notification. |
static <T> NotificationLite<T> |
instance()
Gets the
NotificationLite singleton. |
boolean |
isCompleted(java.lang.Object n)
Indicates whether or not the lite notification represents an
onCompleted event. |
boolean |
isError(java.lang.Object n)
Indicates whether or not the lite notification represents an
onError event. |
Notification.Kind |
kind(java.lang.Object n)
Indicates which variety a particular lite notification is.
|
java.lang.Object |
next(T t)
Creates a lite
onNext notification for the value passed in without doing any allocation. |
public static <T> NotificationLite<T> instance()
NotificationLite
singleton.NotificationLite
objectpublic java.lang.Object next(T t)
onNext
notification for the value passed in without doing any allocation. Can
be unwrapped and sent with the accept(rx.Observer<? super T>, java.lang.Object)
method.t
- the item emitted to onNext
null
public java.lang.Object completed()
onCompleted
notification without doing any allocation. Can be unwrapped and
sent with the accept(rx.Observer<? super T>, java.lang.Object)
method.public java.lang.Object error(java.lang.Throwable e)
onError
notification. This call creates an object to wrap the Throwable
,
but since there should only be one of these, the performance impact should be small. Can be unwrapped and
sent with the accept(rx.Observer<? super T>, java.lang.Object)
method.e
- the Throwable
in the onError
notificationpublic boolean accept(Observer<? super T> o, java.lang.Object n)
Observer
.public boolean isCompleted(java.lang.Object n)
onCompleted
event.n
- the lite notificationtrue
if n
represents an onCompleted
event; false
otherwisepublic boolean isError(java.lang.Object n)
onError
event.n
- the lite notificationtrue
if n
represents an onError
event; false
otherwisepublic Notification.Kind kind(java.lang.Object n)
Observer
then you can use this method to get the
Notification.Kind
.n
- the lite notificationNotification.Kind
of lite notification n
is: either Kind.OnCompleted
,
Kind.OnError
, or Kind.OnNext
java.lang.IllegalArgumentException
- if the notification is null.public T getValue(java.lang.Object n)
OnNext
lite notification. Bad things happen if you pass
this an OnComplete
or OnError
notification type. For performance reasons, this method
does not check for this, so you are expected to prevent such a mishap.n
- the lite notification (of type Kind.OnNext
)public java.lang.Throwable getError(java.lang.Object n)
Throwable
corresponding to this OnError
lite notification. Bad things happen
if you pass this an OnComplete
or OnNext
notification type. For performance reasons, this
method does not check for this, so you are expected to prevent such a mishap.n
- the lite notification (of type Kind.OnError
)Throwable
wrapped inside n