public final class Signal<T> extends Object implements Supplier<T>, Consumer<org.reactivestreams.Subscriber<? super T>>, Serializable
Stream
signal.
There are 4 differents signals and their possible sequence is defined as such:
onError | (onSubscribe onNext* (onError | onComplete)?)Modifier and Type | Class and Description |
---|---|
static class |
Signal.Type |
Modifier and Type | Method and Description |
---|---|
void |
accept(org.reactivestreams.Subscriber<? super T> observer)
Execute the logic of the action, accepting the given parameter.
|
static <T> Signal<T> |
complete()
Creates and returns a
Signal of variety Type.COMPLETE . |
boolean |
equals(Object o) |
static <T> Signal<T> |
error(Throwable e)
Creates and returns a
Signal of variety Type.ERROR , and assigns it an exception. |
T |
get()
Retrieves the item associated with this (onNext) signal.
|
org.reactivestreams.Subscription |
getSubscription()
Read the subscription associated with this (onSubscribe) signal.
|
Throwable |
getThrowable()
Read the exception associated with this (onError) signal.
|
Signal.Type |
getType()
Read the type of this signal:
Subscribe , Next , Error , or Complete |
boolean |
hasError()
Read whether this signal is on error and carries the cause.
|
int |
hashCode() |
boolean |
hasValue()
Has this signal an item associated with it ?
|
boolean |
isOnComplete()
Indicates whether this signal represents an
onComplete event. |
boolean |
isOnError()
Indicates whether this signal represents an
onError event. |
boolean |
isOnNext()
Indicates whether this signal represents an
onNext event. |
boolean |
isOnSubscribe()
Indicates whether this signal represents an
onSubscribe event. |
static <T> Signal<T> |
next(T t)
Creates and returns a
Signal of variety Type.NEXT , and assigns it a value. |
static <T> Signal<T> |
subscribe(org.reactivestreams.Subscription subscription)
Creates and returns a
Signal of variety Type.COMPLETE . |
String |
toString() |
public static <T> Signal<T> next(T t)
Signal
of variety Type.NEXT
, and assigns it a value.t
- the item to assign to the signal as its valueOnNext
variety of Signal
public static <T> Signal<T> error(Throwable e)
Signal
of variety Type.ERROR
, and assigns it an exception.e
- the exception to assign to the signalOnError
variety of Signal
public static <T> Signal<T> complete()
Signal
of variety Type.COMPLETE
.OnCompleted
variety of Signal
public static <T> Signal<T> subscribe(org.reactivestreams.Subscription subscription)
Signal
of variety Type.COMPLETE
.subscription
- the subscriptionOnCompleted
variety of Signal
public Throwable getThrowable()
public org.reactivestreams.Subscription getSubscription()
public T get()
public boolean hasValue()
public boolean hasError()
public Signal.Type getType()
Subscribe
, Next
, Error
, or Complete
public boolean isOnError()
onError
event.onError
eventpublic boolean isOnComplete()
onComplete
event.onSubscribe
eventpublic boolean isOnSubscribe()
onSubscribe
event.onSubscribe
eventpublic boolean isOnNext()
onNext
event.onNext
eventpublic void accept(org.reactivestreams.Subscriber<? super T> observer)
Consumer
Copyright © 2017. All rights reserved.