T - The type of result of the CompletableFuturepublic interface WaitResultBuilder5<T> extends Supplier<Optional<T>>
CompletableFuture to define the
executor it self.| Modifier and Type | Method | Description |
|---|---|---|
default CompletableFuture<Optional<T>> |
asyncExec() |
Create and start the async execution of the
CompletableFuture using
ForkJoinPool.commonPool(). |
default CompletableFuture<Optional<T>> |
asyncExec(Executor executor) |
Deprecated.
Replaced by
using(executor).asyncExec() |
default WaitResultBuilder5<T> |
filter(Predicate<T> filter) |
Add a filter predicate, on the result, if applicable.
|
default Optional<T> |
finish() |
Directly wait for the result of this execution using
ForkJoinPool.commonPool(). |
default Optional<T> |
finish(Executor executor) |
Deprecated.
Replaced by
using(executor).finish() |
default T |
finishWithAResult() |
Directly wait for a positive result of this execution using
ForkJoinPool.commonPool(). |
default T |
finishWithAResult(Executor executor) |
Deprecated.
Replaced by
using(executor).finishWithAResult() |
default <U> WaitResultBuilder5<U> |
flatMap(Function<T,Optional<U>> mapper) |
Add a flat mapper fonction, on the result, if applicable.
|
Optional<T> |
get() |
Directly wait for the result of this execution (the execution is run in this
thread).
|
default <U> WaitResultBuilder5<U> |
map(Function<T,U> mapper) |
Add a mapper fonction, on the result, if applicable.
|
default WaitResultBuilder5<T> |
onFinish(Runnable action) |
Register an action to be done when the retrieval is finish (in success or
not).
|
default WaitResultBuilder5<T> |
or(Supplier<? extends Optional<? extends T>> supplier) |
Add a or operation, on the result, if applicable.
|
default WaitResultBuilder6<T> |
using(Executor executor) |
Define the executor to be used for the async part.
|
default WaitResultBuilder6<T> |
usingDefaultExecutor() |
Define the executor to be used for the async part as using
ForkJoinPool.commonPool(). |
Optional<T> get()
AssertionError is
thrown.
For example :
WaitResult.of(myCallable).dontIgnoreException().expecting(myPredicate).repeat(2)
.every(1000, TimeUnit.MILLISECONDS).get()
myCallable, an AssertionError
is thrownOptional is
returned.Optional.get in interface Supplier<T>Optional with the result of the executionAssertionError - In case of not ignored exception.default WaitResultBuilder5<T> onFinish(Runnable action)
This may be used, for example, to release resources. This method may be used several times. In this case, all the registered action will be executed on Finish, starting by the first one.
action - the action to be done. May be null (ignored).WaitResultBuilder5 with this new action to
be done at the end.default WaitResultBuilder6<T> using(Executor executor)
Both the action to retry and the control on the result will be executed on the thread provided by the executor.
executor - the executor to be used. This can't be null.the final stepdefault WaitResultBuilder6<T> usingDefaultExecutor()
ForkJoinPool.commonPool().
Both the action to retry and the control on the result will be executed on the thread provided by the executor.
the final stepForkJoinPool.commonPool()@Deprecated default CompletableFuture<Optional<T>> asyncExec(Executor executor)
using(executor).asyncExec()CompletableFuture.executor - the executor to be used.CompletableFuturedefault CompletableFuture<Optional<T>> asyncExec()
CompletableFuture using
ForkJoinPool.commonPool().CompletableFutureusingDefaultExecutor(),
WaitResultBuilder6.asyncExec()@Deprecated default Optional<T> finish(Executor executor)
using(executor).finish()AssertionError is thrown.executor - the executor to be used.Optional with the result of the executionAssertionError - In case of not ignored exception.default Optional<T> finish()
ForkJoinPool.commonPool(). In case of not ignored exception, an
AssertionError is thrown.Optional with the result of the executionAssertionError - In case of not ignored exception.usingDefaultExecutor(),
WaitResultBuilder6.finish()@Deprecated default T finishWithAResult(Executor executor)
using(executor).finishWithAResult()AssertionError is
thrown.executor - the executor to be used.AssertionError - In case of not ignored exception or missing result.default T finishWithAResult()
ForkJoinPool.commonPool(). In case of not ignored exception, or when
no result are available, an AssertionError is thrown.AssertionError - In case of not ignored exception or missing result.usingDefaultExecutor(),
WaitResultBuilder6.finishWithAResult()default <U> WaitResultBuilder5<U> map(Function<T,U> mapper)
U - the target of the mapper.mapper - the function to convert the result.WaitResultBuilder5 continuation of the builderOptional.map(Function)default <U> WaitResultBuilder5<U> flatMap(Function<T,Optional<U>> mapper)
U - the target of the mapper.mapper - the function to convert the result.WaitResultBuilder5 continuation of the builderOptional.flatMap(Function)default WaitResultBuilder5<T> or(Supplier<? extends Optional<? extends T>> supplier)
Only available on java 9
supplier - the function to convert the resultWaitResultBuilder5 continuation of the builderOptional.or(Supplier)default WaitResultBuilder5<T> filter(Predicate<T> filter)
filter - the filterWaitResultBuilder5 continuation of the builderOptional.filter(Predicate)Copyright © 2021. All rights reserved.