Package com.batch.android.core
Class Promise<T>
- java.lang.Object
-
- com.batch.android.core.Promise<T>
-
public class Promise<T> extends java.lang.ObjectA 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 static interfacePromise.CatchRunnablestatic interfacePromise.DeferredResultExecutorRunnable<T>Executor that does not automatically resolve the promise once donestatic interfacePromise.ExecutorRunnable<T>Executor that automatically resolves the promise with the returned value once done, even if nullstatic classPromise.Statusstatic interfacePromise.ThenRunnable<T>
-
Constructor Summary
Constructors Constructor Description Promise()Promise(Promise.DeferredResultExecutorRunnable<T> executor)Promise(Promise.ExecutorRunnable<T> executor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Promise<T>catchException(Promise.CatchRunnable catchRunnable)Promise.StatusgetStatus()voidreject(java.lang.Exception exception)static <T> Promise<T>rejected(java.lang.Exception exception)voidresolve(T value)static <T> Promise<T>resolved(T value)Promise<T>then(Promise.ThenRunnable<T> thenRunnable)
-
-
-
Constructor Detail
-
Promise
public Promise()
-
Promise
public Promise(Promise.ExecutorRunnable<T> executor)
-
Promise
public Promise(Promise.DeferredResultExecutorRunnable<T> executor)
-
-
Method Detail
-
resolved
public static <T> Promise<T> resolved(T value)
-
rejected
public static <T> Promise<T> rejected(java.lang.Exception exception)
-
resolve
public void resolve(T value)
-
reject
public void reject(java.lang.Exception exception)
-
then
public Promise<T> then(Promise.ThenRunnable<T> thenRunnable)
-
catchException
public Promise<T> catchException(Promise.CatchRunnable catchRunnable)
-
getStatus
public Promise.Status getStatus()
-
-