Class CompletionSingle<T>
java.lang.Object
io.helidon.common.reactive.CompletionAwaitable<T>
io.helidon.common.reactive.CompletionSingle<T>
- Type Parameters:
T- payload type
- All Implemented Interfaces:
Awaitable<T>, Single<T>, Subscribable<T>, CompletionStage<T>, Flow.Publisher<T>
Single as CompletionStage.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreate a new completion single usingtoNullableStage()as a supplier forCompletionAwaitable.setOriginalStage(java.util.function.Supplier). -
Method Summary
Methods inherited from class CompletionAwaitable
acceptEither, acceptEitherAsync, acceptEitherAsync, applyToEither, applyToEitherAsync, applyToEitherAsync, exceptionally, exceptionallyAccept, handle, handleAsync, handleAsync, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, whenComplete, whenCompleteAsync, whenCompleteAsyncModifier 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) 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.<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) 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) 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) Returns aCompletableFuturemaintaining the same completion properties as this stage.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 class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Awaitable
await, await, await, toCompletableFutureModifier and TypeMethodDescriptiondefault Tawait()Block until future is completed, throws only unchecked exceptions.default TDeprecated.default TBlock until future is completed, throws only unchecked exceptions.Returns aCompletableFuturemaintaining the same completion properties as this stage.Methods inherited from interface CompletionStage
exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsyncMethods inherited from interface Flow.Publisher
subscribeMethods inherited from interface Single
acceptEither, acceptEitherAsync, acceptEitherAsync, applyToEither, applyToEitherAsync, applyToEitherAsync, compose, defaultIfEmpty, defaultIfEmpty, exceptionally, exceptionallyAccept, flatMap, flatMapCompletionStage, flatMapIterable, flatMapOptional, flatMapSingle, forSingle, get, get, handle, handleAsync, handleAsync, ifEmpty, ignoreElement, log, log, log, log, map, observeOn, onComplete, onCompleteResume, onCompleteResumeWith, onCompleteResumeWithSingle, onError, onErrorResume, onErrorResumeWith, onErrorResumeWithSingle, onTerminate, peek, retry, retry, retryWhen, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, switchIfEmpty, takeUntil, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, timeout, timeout, to, toOptionalSingle, toStage, toStage, whenComplete, whenCompleteAsync, whenCompleteAsyncModifier 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) default <U> Single<U> Apply the givencomposerfunction to the currentSingleinstance and return theSinglereturned by this function.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.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) Map thisSingleinstance to a publisher using the given mapper.default <U> Single<U> flatMapCompletionStage(Function<? super T, ? extends CompletionStage<? extends U>> mapper) Transforms item with supplied function and flatten resultingCompletionStageresult to downstream.default <U> Multi<U> flatMapIterable(Function<? super T, ? extends Iterable<? extends U>> mapper) Maps the single upstream value into anIterableand 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 resultingOptionalto 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 resultingSingleto downstream.default CompletionAwaitable<Void> Terminal stage, invokes provided consumer when Single is completed.default Tget()Short-hand fortoFuture().toCompletableFuture().get().default TShort-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 givenRunnablewhen stream is finished without value(empty stream).default CompletionAwaitable<Void> Terminal stage, ignore onNext signals, only onComplete and onError signals are propagated.log()Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.default <U> Single<U> Re-emit the upstream's signals to the downstream on the given executor's thread.onComplete(Runnable onComplete) Executes givenRunnablewhen 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 givenConsumerwhen onError signal is received.onErrorResume(Function<? super Throwable, ? extends T> onError) Functionproviding 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 givenRunnablewhen 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 aTimeoutExceptionif 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.default <U> UApply the givenconverterfunction to the currentSingleinstance and return the value returned by this function.default CompletionStage<T> toStage()Exposes thisSingleinstance as aCompletionStage.default CompletionStage<T> toStage(boolean completeWithoutValue) Exposes thisSingleinstance 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 Subscribable
subscribe, subscribe, subscribe, subscribeModifier and TypeMethodDescriptiondefault voidSubscribe to thisSingleinstance with the given delegate functions.default voidSubscribe to thisSingleinstance with the given delegate functions.default voidsubscribe(Consumer<? super T> consumer, Consumer<? super Throwable> errorConsumer, Runnable completeConsumer) Subscribe to thisSingleinstance with the given delegate functions.default voidsubscribe(Consumer<? super T> consumer, Consumer<? super Throwable> errorConsumer, Runnable completeConsumer, Consumer<? super Flow.Subscription> subscriptionConsumer) Subscribe to thisSingleinstance with the given delegate functions.
-
Constructor Details
-
CompletionSingle
protected CompletionSingle()Create a new completion single usingtoNullableStage()as a supplier forCompletionAwaitable.setOriginalStage(java.util.function.Supplier).
-
-
Method Details
-
toNullableStage
Create a new nullable completable future from this single.- Returns:
- a new nullable completable future
-
onCancel
-
cancel
-
Awaitable.await(Duration)instead