public final class NotificationLite 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.
Modifier and Type | Method and Description |
---|---|
static <T> boolean |
accept(Observer<? super T> o,
Object n)
Unwraps the lite notification and calls the appropriate method on the
Observer . |
static Object |
completed()
Creates a lite
onCompleted notification without doing any allocation. |
static Object |
error(Throwable e)
Create a lite
onError notification. |
static Throwable |
getError(Object n)
Returns the
Throwable corresponding to this OnError lite notification. |
static <T> T |
getValue(Object n)
Returns the item corresponding to this
OnNext lite notification. |
static boolean |
isCompleted(Object n)
Indicates whether or not the lite notification represents an
onCompleted event. |
static boolean |
isError(Object n)
Indicates whether or not the lite notification represents an
onError event. |
static boolean |
isNext(Object n)
Indicates whether or not the lite notification represents an
onNext event. |
static boolean |
isNull(Object n)
Indicates whether or not the lite notification represents a wrapped
null onNext event. |
static <T> Object |
next(T t)
Creates a lite
onNext notification for the value passed in without doing any allocation. |
public static <T> 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 value type to convertt
- the item emitted to onNext
null
public static 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 static Object error(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 static <T> boolean accept(Observer<? super T> o, Object n)
Observer
.T
- the value type to accepto
- the Observer
to call onNext
, onCompleted
, or onError
.n
- the lite notificationtrue
if n
represents a termination event; false
otherwiseIllegalArgumentException
- if the notification is null.NullPointerException
- if the Observer
is null.public static boolean isCompleted(Object n)
onCompleted
event.n
- the lite notificationtrue
if n
represents an onCompleted
event; false
otherwisepublic static boolean isError(Object n)
onError
event.n
- the lite notificationtrue
if n
represents an onError
event; false
otherwisepublic static boolean isNull(Object n)
null
onNext
event.n
- the lite notificationtrue
if n
represents a wrapped null
onNext
event, false
otherwisepublic static boolean isNext(Object n)
onNext
event.n
- the lite notificationtrue
if n
represents an onNext
event, false
otherwisepublic static <T> T getValue(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.T
- the value type to convertn
- the lite notification (of type Kind.OnNext
)public static Throwable getError(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
Copyright © 2018. All rights reserved.