Package io.servicetalk.concurrent.api
Class TestSingle<T>
- java.lang.Object
-
- io.servicetalk.concurrent.api.Single<T>
-
- io.servicetalk.concurrent.api.TestSingle<T>
-
- Type Parameters:
T- Type of the result of thisTestSingle.
- All Implemented Interfaces:
SingleSource<T>
public final class TestSingle<T> extends Single<T> implements SingleSource<T>
ASingle&SingleSourcewhose outgoing signals to itsSingleSource.Subscribers can be controlled.Behavior beyond simply delegating signals to the
SingleSource.Subscriberis accomplished by aFunction<Subscriber<? super T>, Subscriber<? super T>>. ThisFunctionis invoked for everysubscribe(Subscriber)invocation, and the result is used as the delegate for subsequentonSubscribe(Cancellable),onSuccess(Object), andonError(Throwable)calls. SeeTestSingle.Builderfor more information.Defaults
- Allows sequential but not concurrent subscribers.
- Sends
onSubscribe(Cancellable)automatically when subscribed to.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTestSingle.Builder<T>Allows for creatingTestSingles with non-default settings.-
Nested classes/interfaces inherited from interface io.servicetalk.concurrent.SingleSource
SingleSource.Processor<T,R>, SingleSource.Subscriber<T>
-
-
Constructor Summary
Constructors Constructor Description TestSingle()Create aTestSinglewith the defaults.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidhandleSubscribe(SingleSource.Subscriber<? super T> subscriber)Handles a subscriber to thisSingle.booleanisSubscribed()voidonError(java.lang.Throwable t)voidonSubscribe(Cancellable cancellable)Delivers theCancellableto theSingleSource.Subscriber'sSingleSource.Subscriber.onSubscribe(Cancellable).voidonSuccess(T result)Delivers theresultto theSingleSource.Subscriber.voidsubscribe(SingleSource.Subscriber<? super T> subscriber)Subscribe for the result of thisSingleSource.-
Methods inherited from class io.servicetalk.concurrent.api.Single
afterCancel, afterFinally, afterFinally, afterFinally, afterOnError, afterOnSubscribe, afterOnSuccess, afterSubscriber, amb, amb, ambWith, anyOf, anyOf, beforeCancel, beforeFinally, beforeFinally, beforeFinally, beforeOnError, beforeOnSubscribe, beforeOnSuccess, beforeSubscriber, collectUnordered, collectUnordered, collectUnordered, collectUnordered, collectUnorderedDelayError, collectUnorderedDelayError, collectUnorderedDelayError, collectUnorderedDelayError, concat, concat, concat, defer, failed, flatMap, flatMapCompletable, flatMapPublisher, fromCallable, fromFuture, fromStage, fromSupplier, idleTimeout, idleTimeout, idleTimeout, idleTimeout, ignoreElement, liftAsync, liftSync, map, never, onErrorMap, onErrorMap, onErrorMap, onErrorResume, onErrorResume, onErrorResume, onErrorReturn, onErrorReturn, onErrorReturn, publishAndSubscribeOn, publishAndSubscribeOnOverride, publishOn, publishOnOverride, recoverWith, repeat, repeatWhen, retry, retryWhen, subscribe, subscribeInternal, subscribeOn, subscribeOnOverride, subscribeShareContext, succeeded, timeout, timeout, timeout, timeout, toCompletable, toCompletionStage, toFuture, toPublisher, whenCancel, whenFinally, whenFinally, whenFinally, whenOnError, whenOnSubscribe, whenOnSuccess, whenSubscriber, zip, zip, zip, zip, zipWith
-
-
-
-
Method Detail
-
isSubscribed
public boolean isSubscribed()
- Returns:
trueif thisTestSinglehas been subscribed to,falseotherwise.
-
handleSubscribe
protected void handleSubscribe(SingleSource.Subscriber<? super T> subscriber)
Description copied from class:SingleHandles a subscriber to thisSingle.- Specified by:
handleSubscribein classSingle<T>- Parameters:
subscriber- the subscriber.
-
subscribe
public void subscribe(SingleSource.Subscriber<? super T> subscriber)
Description copied from interface:SingleSourceSubscribe for the result of thisSingleSource.- Specified by:
subscribein interfaceSingleSource<T>- Parameters:
subscriber- to subscribe for the result.- See Also:
PublisherSource.subscribe(PublisherSource.Subscriber)
-
onSubscribe
public void onSubscribe(Cancellable cancellable)
Delivers theCancellableto theSingleSource.Subscriber'sSingleSource.Subscriber.onSubscribe(Cancellable).In the case of
auto-on-subscribe, the delegatingCancellablesent to theSingleSource.Subscriberby the auto-on-subscribe will switch tocancellable.- Parameters:
cancellable- theCancellable
-
onSuccess
public void onSuccess(@Nullable T result)Delivers theresultto theSingleSource.Subscriber.- Parameters:
result- the result to deliver.- See Also:
SingleSource.Subscriber.onSuccess(Object)
-
onError
public void onError(java.lang.Throwable t)
- Parameters:
t- the error to deliver.- See Also:
SingleSource.Subscriber.onError(Throwable)
-
-