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., 1.1.0 - Starting from version 1.1.0, the System.Logger feature
        is used to do some logging of the system. One goal is to provide a way
        to the user to see when the system is waiting for example. Also, some
        methods were added to decorate Callable and Predicate
        to add toString to describe them.| Modifier and Type | Method | Description | 
|---|---|---|
static <T> Callable<T> | 
callableWithToString(Callable<T> callable,
                    Supplier<String> toString) | 
 Modify a Callable to add a toString. 
 | 
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 extends Exception> | 
forException(Callable<?> action,
            Class<T> targetException) | 
 Start the builder to create an instance of  
CompletableFuture based on
 repeated control of a call that is assumed as done when a a specific
 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 <T> WaitResultBuilder1<T> | 
of(Callable<T> action,
  Runnable actionOnFinish) | 
 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> WaitResultBuilder1<T> | 
ofSupplier(Supplier<T> supplier) | 
 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. | 
static <T> Predicate<T> | 
predicateWithToString(Predicate<T> predicate,
                     Supplier<String> toString) | 
 Modify a Predicate to add a toString. 
 | 
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 builderNullPointerException - if action is nullpublic static <T> WaitResultBuilder1<T> of(Callable<T> action, Runnable actionOnFinish)
CompletableFuture based on
 the result of the received action, with repetition until some condition.T - The type of the result.action - the Callable providing the result.actionOnFinish - register an action after the result is retrieved (success or
            failure). This may be used to register some resource cleanup.the next step of the builderNullPointerException - if action is nullpublic static <T> WaitResultBuilder1<T> ofSupplier(Supplier<T> supplier)
CompletableFuture based on
 execution of the received action, with repetition until some condition.
 T - The type of the result.supplier - the Supplier to be executed.the next step of the builderNullPointerException - if supplier is nullpublic 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 builderNullPointerException - if action is nullpublic 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 builderNullPointerException - if conditionSupplier is nullpublic 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 builderNullPointerException - if action is nullpublic static <T extends Exception> WaitResultBuilder1<T> forException(Callable<?> action, Class<T> targetException)
CompletableFuture based on
 repeated control of a call that is assumed as done when a a specific
 exception is thrown.T - the expected exception typeaction - the action that is expected to thrown an exception.targetException - the expected Exception classthe next step of the builderNullPointerException - if action or targetException is nullpublic static <T> Callable<T> callableWithToString(Callable<T> callable, Supplier<String> toString)
 The goal of this method is to provide a way to have lambda, used for
 example in the context of this library, that are decorated with a
 toString method. Later, when this Callable is used in log, it is
 possible to have a meaningful description and not the default
 toString.
T - the return type of the Callablecallable - the Callable to be decorated.toString - the Supplier to be used as toString method.NullPointerException - if callable or toString is null.public static <T> Predicate<T> predicateWithToString(Predicate<T> predicate, Supplier<String> toString)
 The goal of this method is to provide a way to have lambda, used for
 example in the context of this library, that are decorated with a
 toString method. Later, when this Predicate is used in log, it is
 possible to have a meaningful description and not the default
 toString.
T - the input type of the Predicate.predicate - the Predicate to be decorated.toString - the Supplier to be used as toString method.NullPointerException - if predicate or toString is null.Copyright © 2021. All rights reserved.