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
&SingleSource
whose outgoing signals to itsSingleSource.Subscriber
s can be controlled.Behavior beyond simply delegating signals to the
SingleSource.Subscriber
is accomplished by aFunction<Subscriber<? super T>, Subscriber<? super T>>
. ThisFunction
is invoked for everysubscribe(Subscriber)
invocation, and the result is used as the delegate for subsequentonSubscribe(Cancellable)
,onSuccess(Object)
, andonError(Throwable)
calls. SeeTestSingle.Builder
for 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 class
TestSingle.Builder<T>
Allows for creatingTestSingle
s 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 aTestSingle
with the defaults.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
handleSubscribe(SingleSource.Subscriber<? super T> subscriber)
Handles a subscriber to thisSingle
.boolean
isSubscribed()
void
onError(java.lang.Throwable t)
void
onSubscribe(Cancellable cancellable)
Delivers theCancellable
to theSingleSource.Subscriber
'sSingleSource.Subscriber.onSubscribe(Cancellable)
.void
onSuccess(T result)
Delivers theresult
to theSingleSource.Subscriber
.void
subscribe(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, zipDelayError, zipDelayError, zipDelayError, zipDelayError, zipWith, zipWithDelayError
-
-
-
-
Method Detail
-
isSubscribed
public boolean isSubscribed()
- Returns:
true
if thisTestSingle
has been subscribed to,false
otherwise.
-
handleSubscribe
protected void handleSubscribe(SingleSource.Subscriber<? super T> subscriber)
Description copied from class:Single
Handles a subscriber to thisSingle
.- Specified by:
handleSubscribe
in classSingle<T>
- Parameters:
subscriber
- the subscriber.
-
subscribe
public void subscribe(SingleSource.Subscriber<? super T> subscriber)
Description copied from interface:SingleSource
Subscribe for the result of thisSingleSource
.- Specified by:
subscribe
in interfaceSingleSource<T>
- Parameters:
subscriber
- to subscribe for the result.- See Also:
PublisherSource.subscribe(PublisherSource.Subscriber)
-
onSubscribe
public void onSubscribe(Cancellable cancellable)
Delivers theCancellable
to theSingleSource.Subscriber
'sSingleSource.Subscriber.onSubscribe(Cancellable)
.In the case of
auto-on-subscribe
, the delegatingCancellable
sent to theSingleSource.Subscriber
by the auto-on-subscribe will switch tocancellable
.- Parameters:
cancellable
- theCancellable
-
onSuccess
public void onSuccess(@Nullable T result)
Delivers theresult
to 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)
-
-