- Type Parameters:
T
- item type
- All Superinterfaces:
Awaitable<T>
,CompletionStage<T>
,Flow.Publisher<T>
,Subscribable<T>
- All Known Implementing Classes:
CompletionSingle
Flow.Publisher
that may: signal one item then completes, complete without
an item or signal an error.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionacceptEither
(CompletionStage<? extends T> other, Consumer<? super T> action) acceptEitherAsync
(CompletionStage<? extends T> other, Consumer<? super T> action) acceptEitherAsync
(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor) <U> CompletionAwaitable<U>
applyToEither
(CompletionStage<? extends T> other, Function<? super T, U> fn) <U> CompletionAwaitable<U>
applyToEitherAsync
(CompletionStage<? extends T> other, Function<? super T, U> fn) <U> CompletionAwaitable<U>
applyToEitherAsync
(CompletionStage<? extends T> other, Function<? super T, U> fn, Executor executor) cancel()
Cancel upstream.default <U> Single<U>
Apply the givencomposer
function to the currentSingle
instance and return theSingle
returned by this function.static <T> Single<T>
static <T> Single<T>
create
(CompletionStage<T> completionStage) Wrap a CompletionStage into a Multi and signal its outcome non-blockingly.static <T> Single<T>
create
(CompletionStage<T> completionStage, boolean nullMeansEmpty) Wrap a CompletionStage into a Multi and signal its outcome non-blockingly.static <T> Single<T>
create
(Flow.Publisher<T> source) Create aSingle
instance that publishes the first and only item received from the given publisher.static <T> Single<T>
Create aSingle
instance that publishes result of the given supplier to its subscriber(s).defaultIfEmpty
(Supplier<? extends T> supplier) Signals the default item supplied by specified supplier if the upstream is empty.defaultIfEmpty
(T defaultItem) Signals the default item if the upstream is empty.static <T> Single<T>
Call the given supplier function for each individual downstream Subscriber to return a Flow.Publisher to subscribe to.static <T> Single<T>
empty()
Get aSingle
instance that completes immediately.static <T> Single<T>
Create aSingle
instance that reports the given given exception to its subscriber(s).exceptionally
(Function<Throwable, ? extends T> fn) exceptionallyAccept
(Consumer<Throwable> consumer) Returns a new CompletionAwaitable that, when this stage completes exceptionally, is executed with this stage's exception as the argument to the supplied consumer.default <U> Multi<U>
flatMap
(Function<? super T, ? extends Flow.Publisher<? extends U>> mapper) default <U> Single<U>
flatMapCompletionStage
(Function<? super T, ? extends CompletionStage<? extends U>> mapper) Transforms item with supplied function and flatten resultingCompletionStage
result to downstream.default <U> Multi<U>
flatMapIterable
(Function<? super T, ? extends Iterable<? extends U>> mapper) Maps the single upstream value into anIterable
and relays its items to the downstream.default <U> Single<U>
flatMapOptional
(Function<? super T, Optional<? extends U>> mapper) Transform item with supplied function and flatten resultingOptional
to downstream as Single with its value as item if present or empty Single.default <U> Single<U>
flatMapSingle
(Function<? super T, ? extends Single<? extends U>> mapper) Transforms item with supplied function and flatten resultingSingle
to downstream.default CompletionAwaitable<Void>
Terminal stage, invokes provided consumer when Single is completed.static <T> Single<T>
Deprecated.static <T> Single<T>
from
(CompletionStage<T> completionStage) Deprecated.usecreate(java.util.concurrent.CompletionStage)
insteadstatic <T> Single<T>
from
(CompletionStage<T> completionStage, boolean nullMeansEmpty) Deprecated.static <T> Single<T>
from
(Flow.Publisher<T> source) Deprecated.usecreate(java.util.concurrent.Flow.Publisher)
insteaddefault T
get()
Short-hand fortoFuture().toCompletableFuture().get()
.default T
Short-hand fortoFuture().toCompletableFuture().get()
.<U> CompletionAwaitable<U>
handle
(BiFunction<? super T, Throwable, ? extends U> fn) <U> CompletionAwaitable<U>
handleAsync
(BiFunction<? super T, Throwable, ? extends U> fn) <U> CompletionAwaitable<U>
handleAsync
(BiFunction<? super T, Throwable, ? extends U> fn, Executor executor) Executes givenRunnable
when stream is finished without value(empty stream).default CompletionAwaitable<Void>
Terminal stage, ignore onNext signals, only onComplete and onError signals are propagated.static <T> Single<T>
just
(T item) Create aSingle
instance that publishes the given item to its subscriber(s).log()
Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.default <U> Single<U>
static <T> Single<T>
never()
Get aSingle
instance that never completes.Re-emit the upstream's signals to the downstream on the given executor's thread.Executes givenRunnable
when a cancel signal is received.onComplete
(Runnable onComplete) Executes givenRunnable
when onComplete signal is received.onCompleteResume
(T item) Resume stream from single item if onComplete signal is intercepted.onCompleteResumeWith
(Flow.Publisher<? extends T> publisher) Resume stream from supplied publisher if onComplete signal is intercepted.Resume stream with supplied single if onComplete signal is intercepted.Executes givenConsumer
when onError signal is received.onErrorResume
(Function<? super Throwable, ? extends T> onError) Function
providing one item to be submitted as onNext in case of onError signal is received.onErrorResumeWith
(Function<? super Throwable, ? extends Flow.Publisher<? extends T>> onError) Resume stream from supplied publisher if onError signal is intercepted.onErrorResumeWithSingle
(Function<? super Throwable, ? extends Single<? extends T>> onError) Resume stream from supplied publisher if onError signal is intercepted.onTerminate
(Runnable onTerminate) Executes givenRunnable
when any of signals onComplete, onCancel or onError is received.Invoke provided consumer for the item in stream.retry
(long count) Retry a failing upstream at most the given number of times before giving up.retry
(BiPredicate<? super Throwable, ? super Long> predicate) Retry a failing upstream if the predicate returns true.retryWhen
(BiFunction<? super Throwable, ? super Long, ? extends Flow.Publisher<U>> whenFunction) Retry a failing upstream when the given function returns a publisher that signals an item.runAfterBoth
(CompletionStage<?> other, Runnable action) runAfterBothAsync
(CompletionStage<?> other, Runnable action) runAfterBothAsync
(CompletionStage<?> other, Runnable action, Executor executor) runAfterEither
(CompletionStage<?> other, Runnable action) runAfterEitherAsync
(CompletionStage<?> other, Runnable action) runAfterEitherAsync
(CompletionStage<?> other, Runnable action, Executor executor) switchIfEmpty
(Single<T> other) Switch to the other Single if the upstream is empty.takeUntil
(Flow.Publisher<U> other) Relay upstream items until the other source signals an item or completes.thenAccept
(Consumer<? super T> action) thenAcceptAsync
(Consumer<? super T> action) thenAcceptAsync
(Consumer<? super T> action, Executor executor) <U> CompletionAwaitable<Void>
thenAcceptBoth
(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) <U> CompletionAwaitable<Void>
thenAcceptBothAsync
(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) <U> CompletionAwaitable<Void>
thenAcceptBothAsync
(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action, Executor executor) <U> CompletionAwaitable<U>
<U> CompletionAwaitable<U>
thenApplyAsync
(Function<? super T, ? extends U> fn) <U> CompletionAwaitable<U>
thenApplyAsync
(Function<? super T, ? extends U> fn, Executor executor) <U,
V> CompletionAwaitable<V> thenCombine
(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) <U,
V> CompletionAwaitable<V> thenCombineAsync
(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) <U,
V> CompletionAwaitable<V> thenCombineAsync
(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn, Executor executor) <U> CompletionAwaitable<U>
thenCompose
(Function<? super T, ? extends CompletionStage<U>> fn) <U> CompletionAwaitable<U>
thenComposeAsync
(Function<? super T, ? extends CompletionStage<U>> fn) <U> CompletionAwaitable<U>
thenComposeAsync
(Function<? super T, ? extends CompletionStage<U>> fn, Executor executor) thenRunAsync
(Runnable action) thenRunAsync
(Runnable action, Executor executor) timeout
(long timeout, TimeUnit unit, ScheduledExecutorService executor) Signals aTimeoutException
if the upstream doesn't signal an item, error or completion within the specified time.timeout
(long timeout, TimeUnit unit, ScheduledExecutorService executor, Single<T> fallback) Switches to a fallback single if the upstream doesn't signal an item, error or completion within the specified time.timer
(long time, TimeUnit unit, ScheduledExecutorService executor) Signal 0L and complete the sequence after the given time elapsed.default <U> U
Apply the givenconverter
function to the currentSingle
instance and return the value returned by this function.default CompletionStage<T>
toStage()
Exposes thisSingle
instance as aCompletionStage
.default CompletionStage<T>
toStage
(boolean completeWithoutValue) Exposes thisSingle
instance as aCompletionStage
.whenComplete
(BiConsumer<? super T, ? super Throwable> action) whenCompleteAsync
(BiConsumer<? super T, ? super Throwable> action) whenCompleteAsync
(BiConsumer<? super T, ? super Throwable> action, Executor executor) Methods inherited from interface io.helidon.common.reactive.Awaitable
await, await, await, toCompletableFuture
Methods inherited from interface java.util.concurrent.CompletionStage
exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync, toCompletableFuture
Methods inherited from interface java.util.concurrent.Flow.Publisher
subscribe
Methods inherited from interface io.helidon.common.reactive.Subscribable
subscribe, subscribe, subscribe, subscribe
-
Method Details
-
defer
Call the given supplier function for each individual downstream Subscriber to return a Flow.Publisher to subscribe to.- Type Parameters:
T
- the element type of the sequence- Parameters:
supplier
- the callback to return a Flow.Publisher for each Subscriber- Returns:
- Multi
- Throws:
NullPointerException
- ifsupplier
isnull
-
empty
Get aSingle
instance that completes immediately.- Type Parameters:
T
- item type- Returns:
- Single
-
error
Create aSingle
instance that reports the given given exception to its subscriber(s). The exception is reported by invokingFlow.Subscriber.onError(java.lang.Throwable)
whenFlow.Publisher.subscribe(Subscriber)
is called.- Type Parameters:
T
- item type- Parameters:
error
- exception to hold- Returns:
- Single
- Throws:
NullPointerException
- if error isnull
-
from
Deprecated.usecreate(java.util.concurrent.CompletionStage)
insteadWrap a CompletionStage into a Multi and signal its outcome non-blockingly.A null result from the CompletionStage will yield a
NullPointerException
signal.- Type Parameters:
T
- the element type of the stage and result- Parameters:
completionStage
- the CompletionStage to- Returns:
- Single
- See Also:
-
from
Deprecated.Wrap a CompletionStage into a Multi and signal its outcome non-blockingly.- Type Parameters:
T
- the element type of the stage and result- Parameters:
completionStage
- the CompletionStage tonullMeansEmpty
- if true, a null result is interpreted to be an empty sequence if false, the resulting sequence fails withNullPointerException
- Returns:
- Single
-
from
Deprecated.usecreate(java.util.concurrent.Flow.Publisher)
insteadCreate aSingle
instance that publishes the first and only item received from the given publisher. Note that if the publisher publishes more than one item, the resultingSingle
will hold an error. UseMulti.first()
instead in order to get the first item of a publisher that may publish more than one item.- Type Parameters:
T
- item type- Parameters:
source
- source publisher- Returns:
- Single
- Throws:
NullPointerException
- if source isnull
-
from
Deprecated.usecreate(io.helidon.common.reactive.Single)
instead- Type Parameters:
T
- item type- Parameters:
single
- sourceSingle
publisher- Returns:
- Single
- Throws:
NullPointerException
- if source isnull
-
create
Wrap a CompletionStage into a Multi and signal its outcome non-blockingly.A null result from the CompletionStage will yield a
NullPointerException
signal.- Type Parameters:
T
- the element type of the stage and result- Parameters:
completionStage
- the CompletionStage to- Returns:
- Single
- See Also:
-
create
Wrap a CompletionStage into a Multi and signal its outcome non-blockingly.- Type Parameters:
T
- the element type of the stage and result- Parameters:
completionStage
- the CompletionStage tonullMeansEmpty
- if true, a null result is interpreted to be an empty sequence if false, the resulting sequence fails withNullPointerException
- Returns:
- Single
-
create
Create aSingle
instance that publishes the first and only item received from the given publisher. Note that if the publisher publishes more than one item, the resultingSingle
will hold an error. UseMulti.first()
instead in order to get the first item of a publisher that may publish more than one item.- Type Parameters:
T
- item type- Parameters:
source
- source publisher- Returns:
- Single
- Throws:
NullPointerException
- if source isnull
-
create
- Type Parameters:
T
- item type- Parameters:
single
- sourceSingle
publisher- Returns:
- Single
- Throws:
NullPointerException
- if source isnull
-
just
Create aSingle
instance that publishes the given item to its subscriber(s).- Type Parameters:
T
- item type- Parameters:
item
- item to publish- Returns:
- Single
- Throws:
NullPointerException
- if item isnull
-
create
Create aSingle
instance that publishes result of the given supplier to its subscriber(s).- Type Parameters:
T
- item type- Parameters:
supplier
- item supplier to publish- Returns:
- Single
- Throws:
NullPointerException
- if item isnull
-
never
Get aSingle
instance that never completes.- Type Parameters:
T
- item type- Returns:
- Single
-
timer
Signal 0L and complete the sequence after the given time elapsed.- Parameters:
time
- the time to wait before signaling 0L and completionunit
- the unit of timeexecutor
- the executor to run the waiting on- Returns:
- Single
- Throws:
NullPointerException
- ifunit
orexecutor
isnull
-
to
Apply the givenconverter
function to the currentSingle
instance and return the value returned by this function.Note that the
converter
function is executed upon calling this method immediately and not when the resulting sequence gets subscribed to.- Type Parameters:
U
- the output type- Parameters:
converter
- the function that receives the currentSingle
instance and should return a value to be returned by the method- Returns:
- the value returned by the function
- Throws:
NullPointerException
- ifconverter
isnull
-
compose
Apply the givencomposer
function to the currentSingle
instance and return theSingle
returned by this function.Note that the
composer
function is executed upon calling this method immediately and not when the resulting sequence gets subscribed to.- Type Parameters:
U
- the output element type- Parameters:
composer
- the function that receives the currentSingle
instance and should return aSingle
to be returned by the method- Returns:
- Single
- Throws:
NullPointerException
- ifcomposer
isnull
-
defaultIfEmpty
Signals the default item if the upstream is empty.- Specified by:
defaultIfEmpty
in interfaceSubscribable<T>
- Parameters:
defaultItem
- the item to signal if the upstream is empty- Returns:
- Single
- Throws:
NullPointerException
- ifdefaultItem
isnull
-
defaultIfEmpty
Signals the default item supplied by specified supplier if the upstream is empty.- Specified by:
defaultIfEmpty
in interfaceSubscribable<T>
- Parameters:
supplier
- of the default value- Returns:
- Multi
- Throws:
NullPointerException
- ifsupplier
isnull
-
flatMap
- Specified by:
flatMap
in interfaceSubscribable<T>
- Type Parameters:
U
- mapped items type- Parameters:
mapper
- mapper- Returns:
- Publisher
- Throws:
NullPointerException
- if mapper isnull
-
flatMapIterable
Maps the single upstream value into anIterable
and relays its items to the downstream.- Specified by:
flatMapIterable
in interfaceSubscribable<T>
- Type Parameters:
U
- the result type- Parameters:
mapper
- the function that receives the single upstream value and should return an Iterable instance- Returns:
- Multi
- Throws:
NullPointerException
- ifmapper
isnull
-
flatMapSingle
Transforms item with supplied function and flatten resultingSingle
to downstream.- Type Parameters:
U
- mapped items type- Parameters:
mapper
- mapper- Returns:
- Single
- Throws:
NullPointerException
- if mapper isnull
-
flatMapCompletionStage
default <U> Single<U> flatMapCompletionStage(Function<? super T, ? extends CompletionStage<? extends U>> mapper) Transforms item with supplied function and flatten resultingCompletionStage
result to downstream. As reactive streams forbids null values, CompletionStage result is mapped toOptional
.- Type Parameters:
U
- mapped items type- Parameters:
mapper
- mapper- Returns:
- Single
- Throws:
NullPointerException
- if mapper isnull
-
flatMapOptional
Transform item with supplied function and flatten resultingOptional
to downstream as Single with its value as item if present or empty Single.- Type Parameters:
U
- mapped item type- Parameters:
mapper
- mapper- Returns:
- Single
- Throws:
NullPointerException
- if mapper isnull
-
map
- Specified by:
map
in interfaceSubscribable<T>
- Type Parameters:
U
- mapped item type- Parameters:
mapper
- mapper- Returns:
- Single
- Throws:
NullPointerException
- if mapper isnull
-
observeOn
Re-emit the upstream's signals to the downstream on the given executor's thread.- Specified by:
observeOn
in interfaceSubscribable<T>
- Parameters:
executor
- the executor to signal the downstream from.- Returns:
- Single
- Throws:
NullPointerException
- ifexecutor
isnull
-
onCancel
Executes givenRunnable
when a cancel signal is received.- Specified by:
onCancel
in interfaceSubscribable<T>
- Parameters:
onCancel
-Runnable
to be executed.- Returns:
- Single
-
onComplete
Executes givenRunnable
when onComplete signal is received.- Specified by:
onComplete
in interfaceSubscribable<T>
- Parameters:
onComplete
-Runnable
to be executed.- Returns:
- Single
-
onError
Executes givenConsumer
when onError signal is received.- Specified by:
onError
in interfaceSubscribable<T>
- Parameters:
onErrorConsumer
-Consumer
to be executed.- Returns:
- Single
-
onErrorResume
Function
providing one item to be submitted as onNext in case of onError signal is received.- Specified by:
onErrorResume
in interfaceSubscribable<T>
- Parameters:
onError
- Function receivingThrowable
as argument and producing one item to resume stream with.- Returns:
- Single
-
onErrorResumeWithSingle
default Single<T> onErrorResumeWithSingle(Function<? super Throwable, ? extends Single<? extends T>> onError) Resume stream from supplied publisher if onError signal is intercepted.- Parameters:
onError
- supplier of new stream publisher- Returns:
- Single
-
onErrorResumeWith
default Multi<T> onErrorResumeWith(Function<? super Throwable, ? extends Flow.Publisher<? extends T>> onError) Resume stream from supplied publisher if onError signal is intercepted.- Specified by:
onErrorResumeWith
in interfaceSubscribable<T>
- Parameters:
onError
- supplier of new stream publisher- Returns:
- Single
-
onCompleteResume
Resume stream from single item if onComplete signal is intercepted. Effectively do anappend
to the stream.- Specified by:
onCompleteResume
in interfaceSubscribable<T>
- Parameters:
item
- one item to resume stream with- Returns:
- Multi
-
onCompleteResumeWith
Resume stream from supplied publisher if onComplete signal is intercepted.- Specified by:
onCompleteResumeWith
in interfaceSubscribable<T>
- Parameters:
publisher
- new stream publisher- Returns:
- Multi
-
onCompleteResumeWithSingle
default Single<T> onCompleteResumeWithSingle(Function<Optional<T>, ? extends Single<? extends T>> onComplete) Resume stream with supplied single if onComplete signal is intercepted.- Parameters:
onComplete
- function for supplying new Single with optional upstream value as a parameter- Returns:
- Single
-
onTerminate
Executes givenRunnable
when any of signals onComplete, onCancel or onError is received.- Specified by:
onTerminate
in interfaceSubscribable<T>
- Parameters:
onTerminate
-Runnable
to be executed.- Returns:
- Single
-
ifEmpty
Executes givenRunnable
when stream is finished without value(empty stream).- Parameters:
ifEmpty
-Runnable
to be executed.- Returns:
- Multi
-
peek
Invoke provided consumer for the item in stream.- Specified by:
peek
in interfaceSubscribable<T>
- Parameters:
consumer
- consumer to be invoked- Returns:
- Single
-
log
Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.- Returns:
- Multi
-
log
Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.- Parameters:
level
- a logging level value- Returns:
- Multi
-
log
Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.- Parameters:
level
- a logging level valueloggerName
- custom logger name- Returns:
- Multi
-
log
Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.Enabled trace option has a negative impact on performance and should NOT be used in production.
- Parameters:
level
- a logging level valuetrace
- if true position of operator is looked up from stack and logged- Returns:
- Multi
-
retry
Retry a failing upstream at most the given number of times before giving up.- Specified by:
retry
in interfaceSubscribable<T>
- Parameters:
count
- the number of times to retry; 0 means no retry at all- Returns:
- Single
- Throws:
IllegalArgumentException
- ifcount
is negative- See Also:
-
retry
Retry a failing upstream if the predicate returns true.- Specified by:
retry
in interfaceSubscribable<T>
- Parameters:
predicate
- the predicate that receives the latest failureThrowable
the number of times the retry happened so far (0-based) and should returntrue
to retry the upstream again orfalse
to signal the latest failure- Returns:
- Single
- Throws:
NullPointerException
- ifpredicate
isnull
- See Also:
-
retryWhen
default <U> Single<T> retryWhen(BiFunction<? super Throwable, ? super Long, ? extends Flow.Publisher<U>> whenFunction) Retry a failing upstream when the given function returns a publisher that signals an item.If the publisher returned by the function completes, the repetition stops and this Single is completed as empty. If the publisher signals an error, the repetition stops and this Single will signal this error.
- Specified by:
retryWhen
in interfaceSubscribable<T>
- Type Parameters:
U
- the element type of the retry-signal sequence- Parameters:
whenFunction
- the function that receives the latest failureThrowable
the number of times the retry happened so far (0-based) and should return aFlow.Publisher
that should signal an item to retry again, complete to stop and complete this Single or signal an error to have this Single emit that error as well.- Returns:
- Single
- Throws:
NullPointerException
- ifwhenFunction
isnull
-
switchIfEmpty
Switch to the other Single if the upstream is empty.- Parameters:
other
- the Single to switch to if the upstream is empty.- Returns:
- Single
- Throws:
NullPointerException
- ifother
isnull
-
takeUntil
Relay upstream items until the other source signals an item or completes.- Specified by:
takeUntil
in interfaceSubscribable<T>
- Type Parameters:
U
- the element type of the other sequence- Parameters:
other
- the other sequence to signal the end of the main sequence- Returns:
- Single
- Throws:
NullPointerException
- ifother
isnull
-
timeout
Signals aTimeoutException
if the upstream doesn't signal an item, error or completion within the specified time.- Specified by:
timeout
in interfaceSubscribable<T>
- Parameters:
timeout
- the time to wait for the upstream to signalunit
- the time unitexecutor
- the executor to use for waiting for the upstream signal- Returns:
- Single
- Throws:
NullPointerException
- ifunit
orexecutor
isnull
-
timeout
default Single<T> timeout(long timeout, TimeUnit unit, ScheduledExecutorService executor, Single<T> fallback) Switches to a fallback single if the upstream doesn't signal an item, error or completion within the specified time.- Parameters:
timeout
- the time to wait for the upstream to signalunit
- the time unitexecutor
- the executor to use for waiting for the upstream signalfallback
- the Single to switch to if the upstream doesn't signal in time- Returns:
- Single
- Throws:
NullPointerException
- ifunit
,executor
orfallback
isnull
-
get
Short-hand fortoFuture().toCompletableFuture().get()
.- Returns:
- T
- Throws:
InterruptedException
- if the current thread was interrupted while waitingExecutionException
- if the future completed exceptionally
-
get
default T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException Short-hand fortoFuture().toCompletableFuture().get()
.- Parameters:
timeout
- the maximum time to waitunit
- the time unit of the timeout argument- Returns:
- T
- Throws:
InterruptedException
- if the current thread was interrupted while waitingExecutionException
- if the future completed exceptionallyTimeoutException
- if the wait timed out
-
toOptionalSingle
Exposes thisSingle
instance as aSingle
withOptional<T>
return type of the asynchronous operation. If thisSingle
completes without a value, the resultingSingle
completes with an emptyOptional
.- Returns:
- CompletionStage
-
toStage
Exposes thisSingle
instance as aCompletionStage
. Note that if thisSingle
completes without a value, the resultingCompletionStage
will be completed exceptionally with anIllegalStateException
- Returns:
- CompletionStage
-
toStage
Exposes thisSingle
instance as aCompletionStage
. Note that if thisSingle
completes without a value andcompleteWithoutValue
is set tofalse
, the resultingCompletionStage
will be completed exceptionally with anIllegalStateException
- Parameters:
completeWithoutValue
- Allow completion without a value.- Returns:
- CompletionStage
-
forSingle
Terminal stage, invokes provided consumer when Single is completed.- Parameters:
consumer
- consumer to be invoked- Returns:
- CompletionStage completed when the stream terminates
-
ignoreElement
Terminal stage, ignore onNext signals, only onComplete and onError signals are propagated.- Returns:
- CompletionStage completed when the stream terminates
-
cancel
Cancel upstream.- Returns:
- new
Single
for eventually received single value.
-
thenApply
- Specified by:
thenApply
in interfaceCompletionStage<T>
-
thenApplyAsync
- Specified by:
thenApplyAsync
in interfaceCompletionStage<T>
-
thenApplyAsync
- Specified by:
thenApplyAsync
in interfaceCompletionStage<T>
-
thenAccept
- Specified by:
thenAccept
in interfaceCompletionStage<T>
-
thenAcceptAsync
- Specified by:
thenAcceptAsync
in interfaceCompletionStage<T>
-
thenAcceptAsync
- Specified by:
thenAcceptAsync
in interfaceCompletionStage<T>
-
thenRun
- Specified by:
thenRun
in interfaceCompletionStage<T>
-
thenRunAsync
- Specified by:
thenRunAsync
in interfaceCompletionStage<T>
-
thenRunAsync
- Specified by:
thenRunAsync
in interfaceCompletionStage<T>
-
thenCombine
<U,V> CompletionAwaitable<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) - Specified by:
thenCombine
in interfaceCompletionStage<T>
-
thenCombineAsync
<U,V> CompletionAwaitable<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) - Specified by:
thenCombineAsync
in interfaceCompletionStage<T>
-
thenCombineAsync
<U,V> CompletionAwaitable<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn, Executor executor) - Specified by:
thenCombineAsync
in interfaceCompletionStage<T>
-
thenAcceptBoth
<U> CompletionAwaitable<Void> thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) - Specified by:
thenAcceptBoth
in interfaceCompletionStage<T>
-
thenAcceptBothAsync
<U> CompletionAwaitable<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) - Specified by:
thenAcceptBothAsync
in interfaceCompletionStage<T>
-
thenAcceptBothAsync
<U> CompletionAwaitable<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action, Executor executor) - Specified by:
thenAcceptBothAsync
in interfaceCompletionStage<T>
-
runAfterBoth
- Specified by:
runAfterBoth
in interfaceCompletionStage<T>
-
runAfterBothAsync
- Specified by:
runAfterBothAsync
in interfaceCompletionStage<T>
-
runAfterBothAsync
CompletionAwaitable<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor) - Specified by:
runAfterBothAsync
in interfaceCompletionStage<T>
-
applyToEither
<U> CompletionAwaitable<U> applyToEither(CompletionStage<? extends T> other, Function<? super T, U> fn) - Specified by:
applyToEither
in interfaceCompletionStage<T>
-
applyToEitherAsync
<U> CompletionAwaitable<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T, U> fn) - Specified by:
applyToEitherAsync
in interfaceCompletionStage<T>
-
applyToEitherAsync
<U> CompletionAwaitable<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T, U> fn, Executor executor) - Specified by:
applyToEitherAsync
in interfaceCompletionStage<T>
-
acceptEither
CompletionAwaitable<Void> acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action) - Specified by:
acceptEither
in interfaceCompletionStage<T>
-
acceptEitherAsync
CompletionAwaitable<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action) - Specified by:
acceptEitherAsync
in interfaceCompletionStage<T>
-
acceptEitherAsync
CompletionAwaitable<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor) - Specified by:
acceptEitherAsync
in interfaceCompletionStage<T>
-
runAfterEither
- Specified by:
runAfterEither
in interfaceCompletionStage<T>
-
runAfterEitherAsync
- Specified by:
runAfterEitherAsync
in interfaceCompletionStage<T>
-
runAfterEitherAsync
CompletionAwaitable<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor) - Specified by:
runAfterEitherAsync
in interfaceCompletionStage<T>
-
thenCompose
- Specified by:
thenCompose
in interfaceCompletionStage<T>
-
thenComposeAsync
- Specified by:
thenComposeAsync
in interfaceCompletionStage<T>
-
thenComposeAsync
<U> CompletionAwaitable<U> thenComposeAsync(Function<? super T, ? extends CompletionStage<U>> fn, Executor executor) - Specified by:
thenComposeAsync
in interfaceCompletionStage<T>
-
handle
- Specified by:
handle
in interfaceCompletionStage<T>
-
handleAsync
- Specified by:
handleAsync
in interfaceCompletionStage<T>
-
handleAsync
<U> CompletionAwaitable<U> handleAsync(BiFunction<? super T, Throwable, ? extends U> fn, Executor executor) - Specified by:
handleAsync
in interfaceCompletionStage<T>
-
whenComplete
- Specified by:
whenComplete
in interfaceCompletionStage<T>
-
whenCompleteAsync
- Specified by:
whenCompleteAsync
in interfaceCompletionStage<T>
-
whenCompleteAsync
CompletionAwaitable<T> whenCompleteAsync(BiConsumer<? super T, ? super Throwable> action, Executor executor) - Specified by:
whenCompleteAsync
in interfaceCompletionStage<T>
-
exceptionally
- Specified by:
exceptionally
in interfaceCompletionStage<T>
-
exceptionallyAccept
Returns a new CompletionAwaitable that, when this stage completes exceptionally, is executed with this stage's exception as the argument to the supplied consumer. Otherwise, if this stage completes normally, then the returned stage also completes normally with the same value.- Parameters:
consumer
- the consumer to invoke if this CompletionAwaitable completed exceptionally- Returns:
- the new CompletionAwaitable
-
create(io.helidon.common.reactive.Single)
instead