Add getResult/hasResult methods to DeferredResult

Issue: SPR-10603
This commit is contained in:
Rossen Stoyanchev
2013-06-20 20:48:33 -04:00
parent 9bc4663ead
commit c6ecaacc03
2 changed files with 32 additions and 1 deletions

View File

@@ -107,6 +107,22 @@ public class DeferredResult<T> {
return ((this.result != RESULT_NONE) || this.expired);
}
/**
* @return {@code true} if the DeferredResult has been set.
*/
public boolean hasResult() {
return this.result != RESULT_NONE;
}
/**
* @return the result or {@code null} if the result wasn't set; since the result can
* also be {@code null}, it is recommended to use {@link #hasResult()} first
* to check if there is a result prior to calling this method.
*/
public Object getResult() {
return hasResult() ? this.result : null;
}
/**
* Return the configured timeout value in milliseconds.
*/