Package com.ocient.util
Class CompletableFutures
java.lang.Object
com.ocient.util.CompletableFutures
public class CompletableFutures extends Object
-
Method Summary
Modifier and Type Method Description static <T> TblockingGet(CompletableFuture<T> future)Returns the result value when complete.static <T> TblockingGet(CompletableFuture<T> future, long timeout, TimeUnit unit)Returns the result value when complete.static ThrowableunwrapThrowable(Throwable t, Class<?>... clazz)Unwraps theThrowablet, returning the underlying root cause.
-
Method Details
-
unwrapThrowable
Unwraps theThrowablet, returning the underlying root cause.Returns
tif:tis not wrapped in aclazzthrowable- OR no root cause is found
- Parameters:
t- the throwable to unwrapclazz- the class representing the wrapping throwable type- Returns:
- the unwrapped
-
blockingGet
public static <T> T blockingGet(CompletableFuture<T> future, long timeout, TimeUnit unit) throws IOExceptionReturns the result value when complete. If the future completes exceptionally, anIOExceptionis thrown.- Type Parameters:
T- the result type- Parameters:
future- the futuretimeout- the timeout valueunit- the timeout unit- Returns:
- the result
- Throws:
IOExceptionCompletionExceptionCancellationException
-
blockingGet
Returns the result value when complete. If the future completes exceptionally, anIOExceptionis thrown.- Type Parameters:
T- the result type- Parameters:
future- the future- Returns:
- the result
- Throws:
IOExceptionCompletionExceptionCancellationException
-