-
public class Promise<T>A simple Promise-like implementation that is not thread-safe. then() can't mutate the value.
Be careful: catch only works for an explicit rejection, NOT automatically for exceptions thrown in ThenRunnables
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfacePromise.ExecutorRunnableExecutor that automatically resolves the promise with the returned value once done, evenif null
public interfacePromise.DeferredResultExecutorRunnableExecutor that does not automatically resolve the promise once done
public interfacePromise.ThenRunnablepublic interfacePromise.CatchRunnablepublic enumPromise.Status
-
Field Summary
Fields Modifier and Type Field Description private Promise.Statusstatus
-
Constructor Summary
Constructors Constructor Description Promise()Promise(Promise.ExecutorRunnable<T> executor)Promise(Promise.DeferredResultExecutorRunnable<T> executor)
-
Method Summary
Modifier and Type Method Description Promise.StatusgetStatus()static <T> Promise<T>resolved(T value)static <T> Promise<T>rejected(Exception exception)synchronized voidresolve(T value)synchronized voidreject(Exception exception)synchronized Promise<T>then(Promise.ThenRunnable<T> thenRunnable)synchronized Promise<T>catchException(Promise.CatchRunnable catchRunnable)-
-
Constructor Detail
-
Promise
Promise()
-
Promise
Promise(Promise.ExecutorRunnable<T> executor)
-
Promise
Promise(Promise.DeferredResultExecutorRunnable<T> executor)
-
-
Method Detail
-
getStatus
Promise.Status getStatus()
-
then
synchronized Promise<T> then(Promise.ThenRunnable<T> thenRunnable)
-
catchException
synchronized Promise<T> catchException(Promise.CatchRunnable catchRunnable)
-
-
-
-