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> T` | `blockingGet​(CompletableFuture<T> future)` | Returns the result value when complete.
`static <T> T` | `blockingGet​(CompletableFuture<T> future, long timeout, TimeUnit unit)` | Returns the result value when complete.
`static Throwable` | `unwrapThrowable​(Throwable t, Class<?>... clazz)` | Unwraps the `Throwable` `t`, returning the underlying root cause.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### unwrapThrowable

public static Throwable unwrapThrowable​(Throwable t, Class<?>... clazz)
Unwraps the `Throwable` `t`, returning the underlying root cause.

Returns `t` if:

- `t` is not wrapped in a `clazz` throwable
- OR no root cause is found

Parameters:
  `t` - the throwable to unwrap
  `clazz` - the class representing the wrapping throwable type
Returns:
  the unwrapped

### blockingGet

public static <T> T blockingGet​(CompletableFuture<T> future, long timeout, TimeUnit unit) throws IOException
Returns the result value when complete. If the future completes exceptionally, an `IOException` is thrown.

Type Parameters:
  `T` - the result type
Parameters:
  `future` - the future
  `timeout` - the timeout value
  `unit` - the timeout unit
Returns:
  the result
Throws:
  `IOException`
  `CompletionException`
  `CancellationException`

### blockingGet

public static <T> T blockingGet​(CompletableFuture<T> future) throws IOException
Returns the result value when complete. If the future completes exceptionally, an `IOException` is thrown.

Type Parameters:
  `T` - the result type
Parameters:
  `future` - the future
Returns:
  the result
Throws:
  `IOException`
  `CompletionException`
  `CancellationException`