public class Promise<T> extends Object implements IPromise<T>
| Modifier and Type | Field and Description |
|---|---|
protected Object |
error |
protected boolean |
hadResult |
protected boolean |
hasFired |
protected Object |
result |
protected Callback |
resultReceiver |
| Constructor and Description |
|---|
Promise()
create an unfulfilled/unsettled Promise
|
Promise(T result)
create a resolved Promise by providing a result (cane be null).
|
Promise(T result,
Object error)
create a settled Promise by either providing an result or error.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
_isHadResult() |
boolean |
_isHasFired() |
T |
await(long timeoutMillis)
see IPromise (inheriting Callback) interface
|
IPromise<T> |
awaitPromise(long timeout)
see IPromise (inheriting Callback) interface
|
<OUT> IPromise<OUT> |
catchError(Consumer<Object> function)
see IPromise (inheriting Callback) interface
|
<OUT> IPromise<OUT> |
catchError(Function<Object,IPromise<OUT>> function)
see IPromise (inheriting Callback) interface
|
void |
complete(Object res,
Object error)
see IPromise (inheriting Callback) interface
|
void |
finallyDo(Callback resultCB)
same as then, but avoid creation of new promise
|
T |
get()
see IPromise (inheriting Callback) interface
|
Object |
getError()
see IPromise (inheriting Callback) interface
|
String |
getId()
remoting helper
|
Promise |
getLast()
see IPromise (inheriting Callback) interface
|
Promise |
getNext()
special method for tricky things.
|
boolean |
isSettled()
see IPromise (inheriting Callback) interface
|
IPromise<T> |
onError(Consumer errorHandler)
see IPromise (inheriting Callback) interface
|
IPromise<T> |
onResult(Consumer<T> resultHandler)
see IPromise (inheriting Callback) interface
|
IPromise<T> |
onTimeout(Consumer timeoutHandler)
see IPromise (inheriting Callback) interface
|
Promise<T> |
setId(String id)
remoting helper
|
IPromise |
then(Callback resultCB)
see IPromise (inheriting Callback) interface
|
<OUT> IPromise<OUT> |
then(Consumer<T> function)
see IPromise (inheriting Callback) interface
|
IPromise<T> |
then(Runnable result)
see IPromise interface
|
<OUT> IPromise<OUT> |
thenAnd(Function<T,IPromise<OUT>> function)
see IPromise (inheriting Callback) interface
|
IPromise<T> |
thenAnd(Supplier<IPromise<T>> callable)
see IPromise (inheriting Callback) interface
|
void |
timedOut(Timeout to)
see IPromise (inheriting Callback) interface
|
IPromise |
timeoutIn(long millis)
see IPromise (inheriting Callback) interface
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitawait, awaitPromise, onTimeoutprotected Object result
protected Object error
protected Callback resultReceiver
protected volatile boolean hadResult
protected boolean hasFired
public Promise(T result, Object error)
result - error - public Promise(T result)
error - public Promise()
public String getId()
public IPromise<T> onResult(Consumer<T> resultHandler)
public IPromise<T> onError(Consumer errorHandler)
public IPromise<T> onTimeout(Consumer timeoutHandler)
public <OUT> IPromise<OUT> thenAnd(Function<T,IPromise<OUT>> function)
public <OUT> IPromise<OUT> then(Consumer<T> function)
public IPromise<T> thenAnd(Supplier<IPromise<T>> callable)
public <OUT> IPromise<OUT> catchError(Function<Object,IPromise<OUT>> function)
catchError in interface IPromise<T>public <OUT> IPromise<OUT> catchError(Consumer<Object> function)
catchError in interface IPromise<T>public void timedOut(Timeout to)
public Promise getNext()
public Promise getLast()
public void finallyDo(Callback resultCB)
resultCB - public final void complete(Object res, Object error)
public T get()
public T await(long timeoutMillis)
public IPromise<T> awaitPromise(long timeout)
awaitPromise in interface IPromise<T>timeout - public IPromise timeoutIn(long millis)
public Object getError()
public boolean isSettled()
public boolean _isHadResult()
public boolean _isHasFired()
Copyright © 2017. All rights reserved.