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.Object
Represents the reactive signal types:onNext
,onError
andonComplete
and holds their parameter values (a value, aThrowable
, nothing).
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static Notification<java.lang.Object>
COMPLETE
The singleton instance for createOnComplete.(package private) java.lang.Object
value
-
Constructor Summary
Constructors Modifier Constructor Description private
Notification(@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 anonComplete
signal.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.boolean
equals(java.lang.Object obj)
@Nullable java.lang.Throwable
getError()
Returns the containerThrowable
error if this notification is anonError
signal, null otherwise.T
getValue()
Returns the contained value if this notification is anonNext
signal, null otherwise.int
hashCode()
boolean
isOnComplete()
Returns true if this notification is anonComplete
signal.boolean
isOnError()
Returns true if this notification is anonError
signal andgetError()
returns the containedThrowable
.boolean
isOnNext()
Returns true if this notification is anonNext
signal andgetValue()
returns the contained value.java.lang.String
toString()
-
-
-
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 anonComplete
signal.- Returns:
- true if this notification is an
onComplete
signal
-
isOnError
public boolean isOnError()
Returns true if this notification is anonError
signal andgetError()
returns the containedThrowable
.- Returns:
- true if this notification is an
onError
signal - See Also:
getError()
-
isOnNext
public boolean isOnNext()
Returns true if this notification is anonNext
signal andgetValue()
returns the contained value.- Returns:
- true if this notification is an
onNext
signal - See Also:
getValue()
-
getValue
@Nullable public T getValue()
Returns the contained value if this notification is anonNext
signal, null otherwise.- Returns:
- the value contained or null
- See Also:
isOnNext()
-
getError
@Nullable public @Nullable java.lang.Throwable getError()
Returns the containerThrowable
error if this notification is anonError
signal, null otherwise.- Returns:
- the
Throwable
error contained ornull
- See Also:
isOnError()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in 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 anonComplete
signal.- Type Parameters:
T
- the target value type- Returns:
- the shared Notification instance representing an
onComplete
signal
-
-