Class SolvablePromise<T>
java.lang.Object
org.smallibs.concurrent.promise.impl.SolvablePromise<T>
- Direct Known Subclasses:
PromisesSet,RunnablePromise,SolvedPromise
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionawait()This method waits for the result.await(java.time.Duration duration) This method waits for the result for a maximum duration.final <R> Promise<R> biMap(FunctionWithError<? super T, ? extends R> onSuccess, FunctionWithError<? super Throwable, ? extends R> onError) Method used to map a function on success and another one on error.protected SolvableFuture<T> createFuture(java.util.function.Consumer<Try<T>> callbackOnComplete) Method called when the current data must be filtered using a given predicate.final <R> Promise<R> Method used to flatmap a function.Provides the underlying future able to capture and returns the result or the error for a given executionfinal <R> Promise<R> map(FunctionWithError<? super T, ? extends R> function) Method used to map a function.onComplete(java.util.function.Consumer<Try<T>> consumer) Callback called when the computation terminatesMethod called when the computation failsMethod called when the computation succeedsself()boolean
-
Constructor Details
-
SolvablePromise
public SolvablePromise()
-
-
Method Details
-
getFuture
Description copied from interface:PromiseProvides the underlying future able to capture and returns the result or the error for a given execution- Returns:
- a future
-
await
Description copied from interface:PromiseThis method waits for the result. This method uses a sleep/interrupt technic.- Throws:
Exception
-
await
Description copied from interface:PromiseThis method waits for the result for a maximum duration. This method uses a sleep/interrupt technic.- Throws:
Exception
-
onSuccess
Description copied from interface:PromiseMethod called when the computation succeeds- Parameters:
consumer- The callback to be activated on success- Returns:
- the current promise
-
onFailure
Description copied from interface:PromiseMethod called when the computation fails- Parameters:
consumer- The callback to be activated on error- Returns:
- the current promise
-
onComplete
Description copied from interface:PromiseCallback called when the computation terminates- Parameters:
consumer- The callback to be activated on completion- Returns:
- the current promise
-
solve
-
createFuture
-
map
Description copied from interface:PromiseMethod used to map a function. This mapping is done when the operation is a success. The result of this mapping is a new promise component. -
biMap
public final <R> Promise<R> biMap(FunctionWithError<? super T, ? extends R> onSuccess, FunctionWithError<? super Throwable, ? extends R> onError) Description copied from interface:PromiseMethod used to map a function on success and another one on error. The result of this mapping is a new promise component. -
flatmap
Description copied from interface:PromiseMethod used to flatmap a function. This mapping is done when the operation is a success. The result of this mapping is a new promise component. -
filter
Description copied from interface:FilterMethod called when the current data must be filtered using a given predicate. -
self
-