public final class WaitResult extends Object
Use one of the provided methods to repeatedly get some data, until some condition.
ch.powerunit.extensions.async. This change is linked with java
9 module, as it will not be possible to have the implementation in a
sub package of the exported one.| Modifier and Type | Method | Description |
|---|---|---|
static WaitResultBuilder3<Exception> |
forException(Callable<?> action) |
Start the builder to create an instance of
CompletableFuture based on
repeated control of a call that is assumed as OK when an exception is thrown. |
static <T> WaitResultBuilder1<T> |
of(Callable<T> action) |
Start the builder to create an instance of
CompletableFuture based on
the result of the received action, with repetition until some condition. |
static WaitResultBuilder3<Boolean> |
ofRunnable(Runnable action) |
Start the builder to create an instance of
CompletableFuture based on
execution of the received action, with repetition until some condition. |
static <T> WaitResultBuilder2<T> |
on(T mutableObject) |
Start the builder to create an instance of
CompletableFuture based on
repeated control on the mutable object. |
static WaitResultBuilder3<Boolean> |
onCondition(Supplier<Boolean> conditionSupplier) |
Start the builder to create an instance of
CompletableFuture based on
repeated control on a method returning a boolean. |
public static <T> WaitResultBuilder1<T> of(Callable<T> action)
CompletableFuture based on
the result of the received action, with repetition until some condition.
CompletableFuture<Optional<MyObject>> exec = WaitResult.of(MyObject::myCallable).expecting(MyObject::myControl)
.repeat(10).every(10, TimeUnit.MILLISECONDS).asyncExec();
T - The type of the result.action - the Callable providing the result.the next step of the builderpublic static WaitResultBuilder3<Boolean> ofRunnable(Runnable action)
CompletableFuture based on
execution of the received action, with repetition until some condition.
In this case, it is assumed that the received action throws unchecked exception when the condition is not yet OK. The returned Optional will be present in case of success.
action - the Runnable to be executed.the next step of the builderpublic static <T> WaitResultBuilder2<T> on(T mutableObject)
CompletableFuture based on
repeated control on the mutable object.
CompletableFuture<Optional<MyObject>> exec = WaitResult.on(myObject).expecting(MyObject::myControl).repeat(100)
.every(10, TimeUnit.MILLISECONDS).asyncExec();
T - The type of the result.mutableObject - the mutable object to be checked.the next step of the builderpublic static WaitResultBuilder3<Boolean> onCondition(Supplier<Boolean> conditionSupplier)
CompletableFuture based on
repeated control on a method returning a boolean.conditionSupplier - the boolean supplierthe next step of the builderpublic static WaitResultBuilder3<Exception> forException(Callable<?> action)
CompletableFuture based on
repeated control of a call that is assumed as OK when an exception is thrown.action - the action that is expected to thrown an exception.the next step of the builderCopyright © 2019. All rights reserved.