public class AsyncResult<T>
extends java.lang.Object
implements java.util.concurrent.Future<T>, java.util.concurrent.CompletionStage<T>
Represents the result of an asynchronous operation.
It implements both Future
and CompletionStage
and is therefore similar to CompletableFuture
, but read-only, i.e. it cannot be completed.
CompletableFuture
Constructor and Description |
---|
AsyncResult(java.util.concurrent.CompletionStage<T> completionStage) |
Modifier and Type | Method and Description |
---|---|
AsyncResult<java.lang.Void> |
acceptEither(java.util.concurrent.CompletionStage<? extends T> other,
java.util.function.Consumer<? super T> action) |
AsyncResult<java.lang.Void> |
acceptEitherAsync(java.util.concurrent.CompletionStage<? extends T> other,
java.util.function.Consumer<? super T> action) |
AsyncResult<java.lang.Void> |
acceptEitherAsync(java.util.concurrent.CompletionStage<? extends T> other,
java.util.function.Consumer<? super T> action,
java.util.concurrent.Executor executor) |
<U> AsyncResult<U> |
applyToEither(java.util.concurrent.CompletionStage<? extends T> other,
java.util.function.Function<? super T,U> fn) |
<U> AsyncResult<U> |
applyToEitherAsync(java.util.concurrent.CompletionStage<? extends T> other,
java.util.function.Function<? super T,U> fn) |
<U> AsyncResult<U> |
applyToEitherAsync(java.util.concurrent.CompletionStage<? extends T> other,
java.util.function.Function<? super T,U> fn,
java.util.concurrent.Executor executor) |
boolean |
cancel()
Cancels the processing of this
Future , i.e. completes it with a CancellationException . |
boolean |
cancel(boolean mayInterruptIfRunning)
Cancels the processing of this
Future , i.e. completes it with a CancellationException . |
AsyncResult<T> |
exceptionally(java.util.function.Function<java.lang.Throwable,? extends T> fn) |
T |
get() |
T |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
T |
getResult()
Waits uninterruptibly on the result of the query and returns it.
|
T |
getResult(long timeout,
java.util.concurrent.TimeUnit unit)
Waits uninterruptibly on the result of the query (with a timeout) and returns it.
|
<U> AsyncResult<U> |
handle(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn) |
<U> AsyncResult<U> |
handleAsync(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn) |
<U> AsyncResult<U> |
handleAsync(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn,
java.util.concurrent.Executor executor) |
boolean |
isCancelled() |
boolean |
isDone() |
AsyncResult<java.lang.Void> |
runAfterBoth(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action) |
AsyncResult<java.lang.Void> |
runAfterBothAsync(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action) |
AsyncResult<java.lang.Void> |
runAfterBothAsync(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action,
java.util.concurrent.Executor executor) |
AsyncResult<java.lang.Void> |
runAfterEither(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action) |
AsyncResult<java.lang.Void> |
runAfterEitherAsync(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action) |
AsyncResult<java.lang.Void> |
runAfterEitherAsync(java.util.concurrent.CompletionStage<?> other,
java.lang.Runnable action,
java.util.concurrent.Executor executor) |
AsyncResult<java.lang.Void> |
thenAccept(java.util.function.Consumer<? super T> action) |
AsyncResult<java.lang.Void> |
thenAcceptAsync(java.util.function.Consumer<? super T> action) |
AsyncResult<java.lang.Void> |
thenAcceptAsync(java.util.function.Consumer<? super T> action,
java.util.concurrent.Executor executor) |
<U> AsyncResult<java.lang.Void> |
thenAcceptBoth(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiConsumer<? super T,? super U> action) |
<U> AsyncResult<java.lang.Void> |
thenAcceptBothAsync(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiConsumer<? super T,? super U> action) |
<U> AsyncResult<java.lang.Void> |
thenAcceptBothAsync(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiConsumer<? super T,? super U> action,
java.util.concurrent.Executor executor) |
<U> AsyncResult<U> |
thenApply(java.util.function.Function<? super T,? extends U> fn) |
<U> AsyncResult<U> |
thenApplyAsync(java.util.function.Function<? super T,? extends U> fn) |
<U> AsyncResult<U> |
thenApplyAsync(java.util.function.Function<? super T,? extends U> fn,
java.util.concurrent.Executor executor) |
<U,V> AsyncResult<V> |
thenCombine(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends V> fn) |
<U,V> AsyncResult<V> |
thenCombineAsync(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends V> fn) |
<U,V> AsyncResult<V> |
thenCombineAsync(java.util.concurrent.CompletionStage<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends V> fn,
java.util.concurrent.Executor executor) |
<U> AsyncResult<U> |
thenCompose(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> fn) |
<U> AsyncResult<U> |
thenComposeAsync(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> fn) |
<U> AsyncResult<U> |
thenComposeAsync(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> fn,
java.util.concurrent.Executor executor) |
AsyncResult<java.lang.Void> |
thenRun(java.lang.Runnable action) |
AsyncResult<java.lang.Void> |
thenRunAsync(java.lang.Runnable action) |
AsyncResult<java.lang.Void> |
thenRunAsync(java.lang.Runnable action,
java.util.concurrent.Executor executor) |
java.util.concurrent.CompletableFuture<T> |
toCompletableFuture() |
AsyncResult<T> |
whenComplete(java.util.function.BiConsumer<? super T,? super java.lang.Throwable> action) |
AsyncResult<T> |
whenCompleteAsync(java.util.function.BiConsumer<? super T,? super java.lang.Throwable> action) |
AsyncResult<T> |
whenCompleteAsync(java.util.function.BiConsumer<? super T,? super java.lang.Throwable> action,
java.util.concurrent.Executor executor) |
public AsyncResult(java.util.concurrent.CompletionStage<T> completionStage)
public <U> AsyncResult<U> thenApply(java.util.function.Function<? super T,? extends U> fn)
thenApply
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<U> thenApplyAsync(java.util.function.Function<? super T,? extends U> fn)
thenApplyAsync
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<U> thenApplyAsync(java.util.function.Function<? super T,? extends U> fn, java.util.concurrent.Executor executor)
thenApplyAsync
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> thenAccept(java.util.function.Consumer<? super T> action)
thenAccept
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> thenAcceptAsync(java.util.function.Consumer<? super T> action)
thenAcceptAsync
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> thenAcceptAsync(java.util.function.Consumer<? super T> action, java.util.concurrent.Executor executor)
thenAcceptAsync
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> thenRun(java.lang.Runnable action)
thenRun
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> thenRunAsync(java.lang.Runnable action)
thenRunAsync
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> thenRunAsync(java.lang.Runnable action, java.util.concurrent.Executor executor)
thenRunAsync
in interface java.util.concurrent.CompletionStage<T>
public <U,V> AsyncResult<V> thenCombine(java.util.concurrent.CompletionStage<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends V> fn)
thenCombine
in interface java.util.concurrent.CompletionStage<T>
public <U,V> AsyncResult<V> thenCombineAsync(java.util.concurrent.CompletionStage<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends V> fn)
thenCombineAsync
in interface java.util.concurrent.CompletionStage<T>
public <U,V> AsyncResult<V> thenCombineAsync(java.util.concurrent.CompletionStage<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends V> fn, java.util.concurrent.Executor executor)
thenCombineAsync
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<java.lang.Void> thenAcceptBoth(java.util.concurrent.CompletionStage<? extends U> other, java.util.function.BiConsumer<? super T,? super U> action)
thenAcceptBoth
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<java.lang.Void> thenAcceptBothAsync(java.util.concurrent.CompletionStage<? extends U> other, java.util.function.BiConsumer<? super T,? super U> action)
thenAcceptBothAsync
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<java.lang.Void> thenAcceptBothAsync(java.util.concurrent.CompletionStage<? extends U> other, java.util.function.BiConsumer<? super T,? super U> action, java.util.concurrent.Executor executor)
thenAcceptBothAsync
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> runAfterBoth(java.util.concurrent.CompletionStage<?> other, java.lang.Runnable action)
runAfterBoth
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> runAfterBothAsync(java.util.concurrent.CompletionStage<?> other, java.lang.Runnable action)
runAfterBothAsync
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> runAfterBothAsync(java.util.concurrent.CompletionStage<?> other, java.lang.Runnable action, java.util.concurrent.Executor executor)
runAfterBothAsync
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<U> applyToEither(java.util.concurrent.CompletionStage<? extends T> other, java.util.function.Function<? super T,U> fn)
applyToEither
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<U> applyToEitherAsync(java.util.concurrent.CompletionStage<? extends T> other, java.util.function.Function<? super T,U> fn)
applyToEitherAsync
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<U> applyToEitherAsync(java.util.concurrent.CompletionStage<? extends T> other, java.util.function.Function<? super T,U> fn, java.util.concurrent.Executor executor)
applyToEitherAsync
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> acceptEither(java.util.concurrent.CompletionStage<? extends T> other, java.util.function.Consumer<? super T> action)
acceptEither
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> acceptEitherAsync(java.util.concurrent.CompletionStage<? extends T> other, java.util.function.Consumer<? super T> action)
acceptEitherAsync
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> acceptEitherAsync(java.util.concurrent.CompletionStage<? extends T> other, java.util.function.Consumer<? super T> action, java.util.concurrent.Executor executor)
acceptEitherAsync
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> runAfterEither(java.util.concurrent.CompletionStage<?> other, java.lang.Runnable action)
runAfterEither
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> runAfterEitherAsync(java.util.concurrent.CompletionStage<?> other, java.lang.Runnable action)
runAfterEitherAsync
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<java.lang.Void> runAfterEitherAsync(java.util.concurrent.CompletionStage<?> other, java.lang.Runnable action, java.util.concurrent.Executor executor)
runAfterEitherAsync
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<U> thenCompose(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> fn)
thenCompose
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<U> thenComposeAsync(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> fn)
thenComposeAsync
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<U> thenComposeAsync(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> fn, java.util.concurrent.Executor executor)
thenComposeAsync
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<T> exceptionally(java.util.function.Function<java.lang.Throwable,? extends T> fn)
exceptionally
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<T> whenComplete(java.util.function.BiConsumer<? super T,? super java.lang.Throwable> action)
whenComplete
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<T> whenCompleteAsync(java.util.function.BiConsumer<? super T,? super java.lang.Throwable> action)
whenCompleteAsync
in interface java.util.concurrent.CompletionStage<T>
public AsyncResult<T> whenCompleteAsync(java.util.function.BiConsumer<? super T,? super java.lang.Throwable> action, java.util.concurrent.Executor executor)
whenCompleteAsync
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<U> handle(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn)
handle
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<U> handleAsync(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn)
handleAsync
in interface java.util.concurrent.CompletionStage<T>
public <U> AsyncResult<U> handleAsync(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn, java.util.concurrent.Executor executor)
handleAsync
in interface java.util.concurrent.CompletionStage<T>
public final java.util.concurrent.CompletableFuture<T> toCompletableFuture()
toCompletableFuture
in interface java.util.concurrent.CompletionStage<T>
public boolean cancel(boolean mayInterruptIfRunning)
Cancels the processing of this Future
, i.e. completes it with a CancellationException
.
public boolean cancel()
Cancels the processing of this Future
, i.e. completes it with a CancellationException
.
This method is a shortcut to cancel(boolean)
, because the boolean parameter has no effect in this implementation.
Future
is now cancelled.public boolean isCancelled()
isCancelled
in interface java.util.concurrent.Future<T>
public boolean isDone()
isDone
in interface java.util.concurrent.Future<T>
public T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get
in interface java.util.concurrent.Future<T>
java.lang.InterruptedException
java.util.concurrent.ExecutionException
public T get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get
in interface java.util.concurrent.Future<T>
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public final T getResult() throws XmppException
Waits uninterruptibly on the result of the query and returns it.
If the thread, waiting on the result is interrupted, this method continues to block until the result is available.
XmppException
- If the response threw an exception.public final T getResult(long timeout, java.util.concurrent.TimeUnit unit) throws XmppException, java.util.concurrent.TimeoutException
Waits uninterruptibly on the result of the query (with a timeout) and returns it.
If the thread, waiting on the result is interrupted, this method continues to block until the result is available or the timeout elapses.
timeout
- The timeoutunit
- The time unit.XmppException
- If the response threw an exception.java.util.concurrent.TimeoutException
- If the result didn’t receive in time.Copyright © 2014–2019 XMPP.rocks. All rights reserved.