Package org.apache.curator.x.async
Interface AsyncResult<T>
-
- Type Parameters:
T- value type
- All Known Implementing Classes:
AsyncResultImpl
public interface AsyncResult<T>Utility that combines the value, the ZooKeeper result code and the exception in one object allowing you to not worry about exceptional completions. i.e. the
CompletionStagereturned byof(AsyncStage)always completes successfully with anAsyncResultobject.All three possible results from a ZooKeeper method are encapsulated in this object. If the ZooKeeper method succeeds, the internal value will be set. If there was a standard ZooKeeper error code (
KeeperException.Code.NODEEXISTS, etc.), that code is set and the value is null. If there was a general exception, that exception is set, the value will be null and the code will beKeeperException.Code.SYSTEMERROR.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcheckError()If there was a general exception or aKeeperExceptionaRuntimeExceptionis thrown that wraps the exception.voidcheckException()If there was a general exception (but not aKeeperException) aRuntimeExceptionis thrown that wraps the exception.org.apache.zookeeper.KeeperException.CodegetCode()Return the ZooKeeper result code.java.util.Optional<java.lang.Throwable>getException()An optional wrapper around any general exceptionjava.lang.ThrowablegetRawException()Return any general exception ornullTgetRawValue()Returns the raw result of the ZooKeeper method ornulljava.util.Optional<T>getValue()An optional wrapper around the ZooKeeper method resultstatic <T> java.util.concurrent.CompletionStage<AsyncResult<T>>of(AsyncStage<T> stage)Return a new stage that wraps an async stage into a result-style completion stage.
-
-
-
Method Detail
-
of
static <T> java.util.concurrent.CompletionStage<AsyncResult<T>> of(AsyncStage<T> stage)
Return a new stage that wraps an async stage into a result-style completion stage. The returned CompletionStage will always complete successfully.- Type Parameters:
T- value type- Parameters:
stage- the stage to wrap- Returns:
- completion stage that resolves to a result
-
getRawValue
T getRawValue()
Returns the raw result of the ZooKeeper method ornull- Returns:
- result or
null
-
getValue
java.util.Optional<T> getValue()
An optional wrapper around the ZooKeeper method result- Returns:
- wrapped result
-
getCode
org.apache.zookeeper.KeeperException.Code getCode()
Return the ZooKeeper result code. If the method was successful,KeeperException.Code.OKis returned. If there was a general exceptionKeeperException.Code.SYSTEMERRORis returned.- Returns:
- result code
-
getRawException
java.lang.Throwable getRawException()
Return any general exception ornull- Returns:
- exception or
null
-
getException
java.util.Optional<java.lang.Throwable> getException()
An optional wrapper around any general exception- Returns:
- wrapped exception
-
checkException
void checkException()
If there was a general exception (but not aKeeperException) aRuntimeExceptionis thrown that wraps the exception. Otherwise, the method returns without any action being performed.
-
checkError
void checkError()
If there was a general exception or aKeeperExceptionaRuntimeExceptionis thrown that wraps the exception. Otherwise, the method returns without any action being performed.
-
-