Package rx
Class Notification<T>
- java.lang.Object
-
- rx.Notification<T>
-
- Type Parameters:
T- the actual value type held by the Notification
public final class Notification<T> extends java.lang.ObjectAn object representing a notification sent to anObservable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNotification.KindSpecifies the kind of the notification: an element, an error or a completion notification.
-
Field Summary
Fields Modifier and Type Field Description private Notification.Kindkindprivate static Notification<java.lang.Void>ON_COMPLETEDprivate java.lang.Throwablethrowableprivate Tvalue
-
Constructor Summary
Constructors Modifier Constructor Description privateNotification(Notification.Kind kind, T value, java.lang.Throwable e)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(Observer<? super T> observer)Forwards this notification on to a specifiedObserver.static <T> Notification<T>createOnCompleted()Creates and returns aNotificationof varietyKind.OnCompleted.static <T> Notification<T>createOnCompleted(java.lang.Class<T> type)Creates and returns aNotificationof varietyKind.OnCompleted.static <T> Notification<T>createOnError(java.lang.Throwable e)Creates and returns aNotificationof varietyKind.OnError, and assigns it an exception.static <T> Notification<T>createOnNext(T t)Creates and returns aNotificationof varietyKind.OnNext, and assigns it a value.booleanequals(java.lang.Object obj)Notification.KindgetKind()Retrieves the kind of this notification:OnNext,OnError, orOnCompletedjava.lang.ThrowablegetThrowable()Retrieves the exception associated with this (onError) notification.TgetValue()Retrieves the item associated with this (onNext) notification.inthashCode()booleanhasThrowable()Indicates whether this notification has an exception associated with it.booleanhasValue()Indicates whether this notification has an item associated with it.booleanisOnCompleted()Indicates whether this notification represents anonCompletedevent.booleanisOnError()Indicates whether this notification represents anonErrorevent.booleanisOnNext()Indicates whether this notification represents anonNextevent.java.lang.StringtoString()
-
-
-
Field Detail
-
kind
private final Notification.Kind kind
-
throwable
private final java.lang.Throwable throwable
-
value
private final T value
-
ON_COMPLETED
private static final Notification<java.lang.Void> ON_COMPLETED
-
-
Constructor Detail
-
Notification
private Notification(Notification.Kind kind, T value, java.lang.Throwable e)
-
-
Method Detail
-
createOnNext
public static <T> Notification<T> createOnNext(T t)
Creates and returns aNotificationof varietyKind.OnNext, and assigns it a value.- Type Parameters:
T- the actual value type held by the Notification- Parameters:
t- the item to assign to the notification as its value- Returns:
- an
OnNextvariety ofNotification
-
createOnError
public static <T> Notification<T> createOnError(java.lang.Throwable e)
Creates and returns aNotificationof varietyKind.OnError, and assigns it an exception.- Type Parameters:
T- the actual value type held by the Notification- Parameters:
e- the exception to assign to the notification- Returns:
- an
OnErrorvariety ofNotification
-
createOnCompleted
public static <T> Notification<T> createOnCompleted()
Creates and returns aNotificationof varietyKind.OnCompleted.- Type Parameters:
T- the actual value type held by the Notification- Returns:
- an
OnCompletedvariety ofNotification
-
createOnCompleted
public static <T> Notification<T> createOnCompleted(java.lang.Class<T> type)
Creates and returns aNotificationof varietyKind.OnCompleted.- Type Parameters:
T- the actual value type held by the Notification- Parameters:
type-- Returns:
- an
OnCompletedvariety ofNotification
-
getThrowable
public java.lang.Throwable getThrowable()
Retrieves the exception associated with this (onError) notification.- Returns:
- the Throwable associated with this (onError) notification
-
getValue
public T getValue()
Retrieves the item associated with this (onNext) notification.- Returns:
- the item associated with this (onNext) notification
-
hasValue
public boolean hasValue()
Indicates whether this notification has an item associated with it.- Returns:
- a boolean indicating whether or not this notification has an item associated with it
-
hasThrowable
public boolean hasThrowable()
Indicates whether this notification has an exception associated with it.- Returns:
- a boolean indicating whether this notification has an exception associated with it
-
getKind
public Notification.Kind getKind()
Retrieves the kind of this notification:OnNext,OnError, orOnCompleted- Returns:
- the kind of the notification:
OnNext,OnError, orOnCompleted
-
isOnError
public boolean isOnError()
Indicates whether this notification represents anonErrorevent.- Returns:
- a boolean indicating whether this notification represents an
onErrorevent
-
isOnCompleted
public boolean isOnCompleted()
Indicates whether this notification represents anonCompletedevent.- Returns:
- a boolean indicating whether this notification represents an
onCompletedevent
-
isOnNext
public boolean isOnNext()
Indicates whether this notification represents anonNextevent.- Returns:
- a boolean indicating whether this notification represents an
onNextevent
-
accept
public void accept(Observer<? super T> observer)
Forwards this notification on to a specifiedObserver.- Parameters:
observer- the target observer to call onXXX methods on based on the kind of this Notification instance
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-