public abstract class Promises
extends java.lang.Object
| Constructor and Description |
|---|
Promises() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Promise<T> |
any(java.util.Collection<? extends Promise<T>> promises)
Pick the first result coming from any of the given promises and populate a new Promise.
|
static <T> Promise<T> |
any(Deferred<T,Promise<T>>... promises)
Pick the first result coming from any of the given promises and populate a new Promise.
|
static <T> Promise<T> |
any(Promise<T>... promises)
Pick the first result coming from any of the given promises and populate a new Promise.
|
static <T> DeferredPromiseSpec<T> |
defer()
|
static <T> Deferred<T,Promise<T>> |
defer(Environment env)
|
static <T> Deferred<T,Promise<T>> |
defer(Environment env,
Dispatcher dispatcher)
|
static <T> Deferred<T,Promise<T>> |
defer(Environment env,
java.lang.String dispatcher)
|
static <T> PromiseSpec<T> |
error(java.lang.Throwable error)
|
static <T> Promise<T> |
next(Composable<T> composable)
Consume the next value of the given
Composable and fulfill the returned Promise on the next value. |
static <T> PromiseSpec<T> |
success(T value)
|
static <T> PromiseSpec<T> |
task(Supplier<T> supplier)
|
static <T> Promise<java.util.List<T>> |
when(java.util.Collection<? extends Promise<T>> promises)
Aggregate given promises into a new a Promise that will be fulfilled when all of the given Promise Promises have been fulfilled.
|
static <T> Promise<java.util.List<T>> |
when(Deferred<T,Promise<T>>... promises)
Merge given deferred promises into a new a Promise that will be fulfilled when all of the given
Deferred Deferreds have been fulfilled.
|
static <T> Promise<java.util.List<T>> |
when(Promise<T>... promises)
Merge given promises into a new a Promise that will be fulfilled when all of the given Promise
Promises have been fulfilled.
|
public static <T> Deferred<T,Promise<T>> defer(Environment env)
T - type of the expected valueenv - the Environment to useDeferredpublic static <T> Deferred<T,Promise<T>> defer(Environment env, java.lang.String dispatcher)
T - type of the expected valueenv - the Environment to usedispatcher - the name of the Dispatcher to useDeferredpublic static <T> Deferred<T,Promise<T>> defer(Environment env, Dispatcher dispatcher)
T - type of the expected valueenv - the Environment to usedispatcher - the Dispatcher to useDeferredpublic static <T> DeferredPromiseSpec<T> defer()
T - type of the expected valueDeferredPromiseSpec.public static <T> PromiseSpec<T> task(Supplier<T> supplier)
Deferred backed by a Promise and producing the value for the Promise using the
given supplier.T - type of the expected valuesupplier - Supplier that will produce the valuePromiseSpec.public static <T> PromiseSpec<T> success(T value)
T - the type of the valuevalue - the value to complete the Promise withPromiseSpec that will produce a Promise that is completed with the given valuepublic static <T> PromiseSpec<T> error(java.lang.Throwable error)
T - the type of the valueerror - the error to complete the Promise withPromiseSpec that will produce a Promise that is completed with the given errorpublic static <T> Promise<java.util.List<T>> when(Promise<T>... promises)
T - The type of the function result.promises - The promises to use.Promise.public static <T> Promise<java.util.List<T>> when(Deferred<T,Promise<T>>... promises)
T - The type of the function result.promises - The promises to use.Promise.public static <T> Promise<java.util.List<T>> when(java.util.Collection<? extends Promise<T>> promises)
T - The type of the function result.promises - The promises to use.DeferredPromiseSpec.public static <T> Promise<T> any(Deferred<T,Promise<T>>... promises)
T - The type of the function result.promises - The deferred promises to use.Promise.public static <T> Promise<T> any(Promise<T>... promises)
T - The type of the function result.promises - The deferred promises to use.Promise.public static <T> Promise<T> any(java.util.Collection<? extends Promise<T>> promises)
T - The type of the function result.promises - The promises to use.DeferredStreamSpec.public static <T> Promise<T> next(Composable<T> composable)
Composable and fulfill the returned Promise on the next value.T - type of the valuecomposable - the Composable to consume the next value fromPromise that will be fulfilled with the next value coming into the given
Composable