Modifier and Type | Method and Description |
---|---|
static Promise<Void,NeverThrowsException> |
allDone(Collection<Promise<?,?>> promises)
Returns a
Promise which will be completed successfully once all of the
provided promises have completed (successfully or not, including runtime exceptions). |
static <V> Promise<V,NeverThrowsException> |
allDone(Collection<Promise<?,?>> promises,
V context)
Returns a
Promise which will be completed successfully once all of the
provided promises have completed (successfully or not, including runtime exceptions),
returning back the context parameter. |
static <V,E extends Exception> |
anyResultFrom(Stream<Promise<V,E>> promises)
Takes a stream of promises that may not yet be resolved and returns a resolved value from them, or if none
resolve to a result, the failure from the last.
|
static <V,E extends Exception> |
newExceptionPromise(E exception)
Returns a
Promise representing an asynchronous task which has
already failed with the provided exception. |
static <V,E extends Exception> |
newResultPromise(V result)
Returns a
Promise representing an asynchronous task which has
already succeeded with the provided result. |
static <V,E extends Exception> |
newRuntimeExceptionPromise(RuntimeException exception)
Returns a
Promise representing an asynchronous task which has
already failed with the provided runtime exception. |
static <V,E extends Exception> |
when(List<Promise<V,E>> promises)
Returns a
Promise which will be completed once all of the
provided promises have succeeded, or as soon as one of them fails. |
static <V,E extends Exception> |
when(Promise<V,E>... promises)
Returns a
Promise which will be completed once all of the
provided promises have succeeded, or as soon as one of them fails. |
public static <V,E extends Exception> Promise<V,E> newRuntimeExceptionPromise(RuntimeException exception)
Promise
representing an asynchronous task which has
already failed with the provided runtime exception. Attempts to get the result will
immediately fail, and any listeners registered against the returned
promise will be immediately invoked in the same thread as the caller.V
- The type of the task's result, or Void
if the task
does not return anything (i.e. it only has side-effects).E
- The type of the exception thrown by the task if it fails, or
NeverThrowsException
if the task cannot fail.exception
- The exception indicating why the asynchronous task has failed.Promise
representing an asynchronous task which has
already failed with the provided exception.public static <V,E extends Exception> Promise<V,E> newExceptionPromise(E exception)
Promise
representing an asynchronous task which has
already failed with the provided exception. Attempts to get the result will
immediately fail, and any listeners registered against the returned
promise will be immediately invoked in the same thread as the caller.V
- The type of the task's result, or Void
if the task
does not return anything (i.e. it only has side-effects).E
- The type of the exception thrown by the task if it fails, or
NeverThrowsException
if the task cannot fail.exception
- The exception indicating why the asynchronous task has failed.Promise
representing an asynchronous task which has
already failed with the provided exception.public static <V,E extends Exception> Promise<V,E> newResultPromise(V result)
Promise
representing an asynchronous task which has
already succeeded with the provided result. Attempts to get the result
will immediately return the result, and any listeners registered against
the returned promise will be immediately invoked in the same thread as
the caller.V
- The type of the task's result, or Void
if the task
does not return anything (i.e. it only has side-effects).E
- The type of the exception thrown by the task if it fails, or
NeverThrowsException
if the task cannot fail.result
- The result of the asynchronous task.Promise
representing an asynchronous task which has
already succeeded with the provided result.public static <V,E extends Exception> Promise<List<V>,E> when(List<Promise<V,E>> promises)
Promise
which will be completed once all of the
provided promises have succeeded, or as soon as one of them fails.V
- The type of the tasks' result, or Void
if the tasks do
not return anything (i.e. they only has side-effects).E
- The type of the exception thrown by the tasks if they fail, or
NeverThrowsException
if the tasks cannot fail.promises
- The list of tasks to be combined.Promise
which will be completed once all of the
provided promises have succeeded, or as soon as one of them
fails.@SafeVarargs public static <V,E extends Exception> Promise<List<V>,E> when(Promise<V,E>... promises)
Promise
which will be completed once all of the
provided promises have succeeded, or as soon as one of them fails.V
- The type of the tasks' result, or Void
if the tasks do
not return anything (i.e. they only has side-effects).E
- The type of the exception thrown by the tasks if they fail, or
NeverThrowsException
if the tasks cannot fail.promises
- The list of tasks to be combined.Promise
which will be completed once all of the
provided promises have succeeded, or as soon as one of them
has thrown an exception.public static <V,E extends Exception> Optional<Promise<V,E>> anyResultFrom(Stream<Promise<V,E>> promises)
V
- The type of promise value.E
- The type of promise exception.promises
- The promises.public static Promise<Void,NeverThrowsException> allDone(Collection<Promise<?,?>> promises)
Promise
which will be completed successfully once all of the
provided promises have completed (successfully or not, including runtime exceptions).promises
- The collection of tasks to be combined.Promise
which will be completed successfully once all of the
provided promises have completed (successfully or not).public static <V> Promise<V,NeverThrowsException> allDone(Collection<Promise<?,?>> promises, V context)
Promise
which will be completed successfully once all of the
provided promises have completed (successfully or not, including runtime exceptions),
returning back the context
parameter.V
- The type of the promise' result (can be Void
).promises
- The collection of tasks to be combined.context
- Instance passed back to the resulting promise on completion (can be null
)Promise
which will be completed successfully once all of the provided
promises have completed (successfully or not).Copyright © 2010-2018, ForgeRock All Rights Reserved.