Package io.reactivex.rxjava3.core
Class Notification<T>
- java.lang.Object
-
- io.reactivex.rxjava3.core.Notification<T>
-
- Type Parameters:
T- the value type
public final class Notification<T> extends java.lang.ObjectRepresents the reactive signal types:onNext,onErrorandonCompleteand holds their parameter values (a value, aThrowable, nothing).
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static Notification<java.lang.Object>COMPLETEThe singleton instance for createOnComplete.(package private) java.lang.Objectvalue
-
Constructor Summary
Constructors Modifier Constructor Description privateNotification(@Nullable java.lang.Object value)Not meant to be implemented externally.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> @NonNull Notification<T>createOnComplete()Returns the empty and stateless shared instance of a notification representing anonCompletesignal.static <T> @NonNull Notification<T>createOnError(@NonNull java.lang.Throwable error)Constructs an onError notification containing the error.static <@NonNull T>
@NonNull Notification<T>createOnNext(@NonNull T value)Constructs an onNext notification containing the given value.booleanequals(java.lang.Object obj)@Nullable java.lang.ThrowablegetError()Returns the containerThrowableerror if this notification is anonErrorsignal, null otherwise.TgetValue()Returns the contained value if this notification is anonNextsignal, null otherwise.inthashCode()booleanisOnComplete()Returns true if this notification is anonCompletesignal.booleanisOnError()Returns true if this notification is anonErrorsignal andgetError()returns the containedThrowable.booleanisOnNext()Returns true if this notification is anonNextsignal andgetValue()returns the contained value.java.lang.StringtoString()
-
-
-
Field Detail
-
value
final java.lang.Object value
-
COMPLETE
static final Notification<java.lang.Object> COMPLETE
The singleton instance for createOnComplete.
-
-
Method Detail
-
isOnComplete
public boolean isOnComplete()
Returns true if this notification is anonCompletesignal.- Returns:
- true if this notification is an
onCompletesignal
-
isOnError
public boolean isOnError()
Returns true if this notification is anonErrorsignal andgetError()returns the containedThrowable.- Returns:
- true if this notification is an
onErrorsignal - See Also:
getError()
-
isOnNext
public boolean isOnNext()
Returns true if this notification is anonNextsignal andgetValue()returns the contained value.- Returns:
- true if this notification is an
onNextsignal - See Also:
getValue()
-
getValue
@Nullable public T getValue()
Returns the contained value if this notification is anonNextsignal, null otherwise.- Returns:
- the value contained or null
- See Also:
isOnNext()
-
getError
@Nullable public @Nullable java.lang.Throwable getError()
Returns the containerThrowableerror if this notification is anonErrorsignal, null otherwise.- Returns:
- the
Throwableerror contained ornull - See Also:
isOnError()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
createOnNext
@NonNull public static <@NonNull T> @NonNull Notification<T> createOnNext(@NonNull T value)
Constructs an onNext notification containing the given value.- Type Parameters:
T- the value type- Parameters:
value- the value to carry around in the notification, notnull- Returns:
- the new Notification instance
- Throws:
java.lang.NullPointerException- if value isnull
-
createOnError
@NonNull public static <T> @NonNull Notification<T> createOnError(@NonNull @NonNull java.lang.Throwable error)
Constructs an onError notification containing the error.- Type Parameters:
T- the value type- Parameters:
error- the error Throwable to carry around in the notification, not null- Returns:
- the new Notification instance
- Throws:
java.lang.NullPointerException- if error isnull
-
createOnComplete
@NonNull public static <T> @NonNull Notification<T> createOnComplete()
Returns the empty and stateless shared instance of a notification representing anonCompletesignal.- Type Parameters:
T- the target value type- Returns:
- the shared Notification instance representing an
onCompletesignal
-
-