Top Description Inners Fields Constructors Methods
rx.internal.operators

public final Class NotificationLite

extends Object
Class Inheritance
Imports
java.io.Serializable, rx.Observer

For use in internal operators that need something like materialize and dematerialize wholly within the implementation of the operator but don't want to incur the allocation cost of actually creating rx.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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final Object
private static final Object

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
the value type to accept
T
>
boolean

Returns:

true if n represents a termination event; false otherwise
accept
(Observer<? super T>
the Observer to call onNext, onCompleted, or onError.
o
,
Object
the lite notification
n
)

Unwraps the lite notification and calls the appropriate method on the Observer.

public static Object

Returns:

a completion token
completed
()

Creates a lite onCompleted notification without doing any allocation.

public static Object

Returns:

an object encapsulating the exception
error
(Throwable
the Throwable in the onError notification
e
)

Create a lite onError notification.

public static Throwable

Returns:

the Throwable wrapped inside n
getError
(Object
the lite notification (of type Kind.OnError)
n
)

Returns the Throwable corresponding to this OnError lite notification.

public static <
the value type to convert
T
>
T

Returns:

the unwrapped value, which can be null
getValue
(Object
the lite notification (of type Kind.OnNext)
n
)

Returns the item corresponding to this OnNext lite notification.

public static boolean

Returns:

true if n represents an onCompleted event; false otherwise
isCompleted
(Object
the lite notification
n
)

Indicates whether or not the lite notification represents an onCompleted event.

public static boolean

Returns:

true if n represents an onError event; false otherwise
isError
(Object
the lite notification
n
)

Indicates whether or not the lite notification represents an onError event.

public static boolean

Returns:

true if n represents an onNext event, false otherwise
isNext
(Object
the lite notification
n
)

Indicates whether or not the lite notification represents an onNext event.

public static boolean

Returns:

true if n represents a wrapped null onNext event, false otherwise
isNull
(Object
the lite notification
n
)

Indicates whether or not the lite notification represents a wrapped null onNext event.

public static <
the value type to convert
T
>
Object

Returns:

the item, or a null token representing the item if the item is null
next
(T
the item emitted to onNext
t
)

Creates a lite onNext notification for the value passed in without doing any allocation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ON_COMPLETED_SENTINELback to summary
private static final Object ON_COMPLETED_SENTINEL
ON_NEXT_NULL_SENTINELback to summary
private static final Object ON_NEXT_NULL_SENTINEL

Constructor Detail

NotificationLiteback to summary
private NotificationLite()

Method Detail

acceptback to summary
public static <T> boolean accept(Observer<? super T> o, Object n)

Unwraps the lite notification and calls the appropriate method on the Observer.

Parameters
<T>
the value type to accept
o:Observer<? super T>

the Observer to call onNext, onCompleted, or onError.

n:Object

the lite notification

Returns:boolean

true if n represents a termination event; false otherwise

Annotations
@SuppressWarnings:unchecked
Exceptions
IllegalArgumentException:
if the notification is null.
NullPointerException:
if the Observer is null.
completedback to summary
public static Object completed()

Creates a lite onCompleted notification without doing any allocation. Can be unwrapped and sent with the accept method.

Returns:Object

a completion token

errorback to summary
public static Object error(Throwable e)

Create a lite 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 method.

Parameters
e:Throwable

the Throwable in the onError notification

Returns:Object

an object encapsulating the exception

getErrorback to summary
public static Throwable getError(Object n)

Returns the 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.

Parameters
n:Object

the lite notification (of type Kind.OnError)

Returns:Throwable

the Throwable wrapped inside n

getValueback to summary
public static <T> T getValue(Object n)

Returns the item corresponding to this 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.

Parameters
<T>
the value type to convert
n:Object

the lite notification (of type Kind.OnNext)

Returns:T

the unwrapped value, which can be null

Annotations
@SuppressWarnings:unchecked
isCompletedback to summary
public static boolean isCompleted(Object n)

Indicates whether or not the lite notification represents an onCompleted event.

Parameters
n:Object

the lite notification

Returns:boolean

true if n represents an onCompleted event; false otherwise

isErrorback to summary
public static boolean isError(Object n)

Indicates whether or not the lite notification represents an onError event.

Parameters
n:Object

the lite notification

Returns:boolean

true if n represents an onError event; false otherwise

isNextback to summary
public static boolean isNext(Object n)

Indicates whether or not the lite notification represents an onNext event.

Parameters
n:Object

the lite notification

Returns:boolean

true if n represents an onNext event, false otherwise

isNullback to summary
public static boolean isNull(Object n)

Indicates whether or not the lite notification represents a wrapped null onNext event.

Parameters
n:Object

the lite notification

Returns:boolean

true if n represents a wrapped null onNext event, false otherwise

nextback to summary
public static <T> Object next(T t)

Creates a lite onNext notification for the value passed in without doing any allocation. Can be unwrapped and sent with the accept method.

Parameters
<T>
the value type to convert
t:T

the item emitted to onNext

Returns:Object

the item, or a null token representing the item if the item is null

rx.internal.operators back to summary

pack-priv final Class NotificationLite.OnErrorSentinel

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

Field Summary

Modifier and TypeField and Description
pack-priv final Throwable
e

private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

eback to summary
pack-priv final Throwable e
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

OnErrorSentinelback to summary
public OnErrorSentinel(Throwable e)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override