T -
public final class NotificationLite<T> extends 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
Unwraps the lite notification and calls the appropriate method on the
Observer.
|
Object |
completed()
Creates a lite
onCompleted notification without doing any allocation.
|
Object |
error(Throwable
Create a lite
onError notification.
|
Throwable |
getError(Object
Returns the
Throwable corresponding to this
OnError lite notification.
|
T |
getValue(Object
Returns the item corresponding to this
OnNext lite notification.
|
static <T> NotificationLite |
instance()
Gets the
NotificationLite singleton.
|
boolean |
isCompleted(Object
Indicates whether or not the lite notification represents an
onCompleted event.
|
boolean |
isError(Object
Indicates whether or not the lite notification represents an
onError event.
|
Notification |
kind(Object
Indicates which variety a particular lite notification is.
|
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 object
public Objectnext(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 Objectcompleted()
onCompleted notification without doing any allocation. Can be unwrapped and sent with the
accept(rx.Observer<? super T>, java.lang.Object) method.
public Objecterror(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 notification
public boolean accept(Observer<? super T> o, Object n)
Observer.
o - the
Observer to call
onNext,
onCompleted, or
onError.
n - the lite notification
true if
n represents a termination event;
false otherwise
IllegalArgumentException - if the notification is null.
NullPointerException - if the
Observer is null.
public boolean isCompleted(Objectn)
onCompleted event.
n - the lite notification
true if
n represents an
onCompleted event;
false otherwise
public boolean isError(Objectn)
onError event.
n - the lite notification
true if
n represents an
onError event;
false otherwise
public Notification.Kind kind(Object n)
Observer then you can use this method to get the
Notification.Kind.
n - the lite notification
Notification.Kind of lite notification
n is: either
Kind.OnCompleted,
Kind.OnError, or
Kind.OnNext
IllegalArgumentException - if the notification is null.
public T getValue(Objectn)
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 ThrowablegetError(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