IDEA-55568 Allow AsyncResult to return value when rejected

This commit is contained in:
Kirill Kalishev
2010-06-07 15:02:10 +04:00
parent fbd5a33336
commit 05de46ddbc
@@ -25,6 +25,12 @@ public class AsyncResult<T> extends ActionCallback {
return this;
}
public AsyncResult<T> setRejected(T result) {
myResult = result;
super.setRejected();
return this;
}
public AsyncResult<T> doWhenDone(final Handler<T> handler) {
doWhenDone(new Runnable() {
public void run() {
@@ -34,6 +40,15 @@ public class AsyncResult<T> extends ActionCallback {
return this;
}
public AsyncResult<T> doWhenRejected(final Handler<T> handler) {
doWhenRejected(new Runnable() {
public void run() {
handler.run(myResult);
}
});
return this;
}
public T getResult() {
return myResult;
}
@@ -52,6 +67,10 @@ public class AsyncResult<T> extends ActionCallback {
public Rejected() {
setRejected();
}
public Rejected(T value) {
setRejected(value);
}
}
}