Class FutureHelper (2.0.0)

public final class FutureHelper

Utilities for working with Futures in the synchronous datastore api.

Inheritance

java.lang.Object > FutureHelper

Static Methods

<T,E>quietGet(Future<T> future, Class<E> exceptionClass)

public static T <T,E>quietGet(Future<T> future, Class<E> exceptionClass)

Return the result of the provided Future, converting all checked exceptions except those of the provided type to unchecked exceptions so the caller doesn't have to handle them. If an ExecutionException is thrown and the type of the cause does not equal exceptionClass the cause is wrapped in a RuntimeException. If the type of the cause does equal exceptionClass the cause itself is thrown. If an InterruptedException is thrown it is wrapped in a DatastoreFailureException.

Parameters
NameDescription
futureFuture<T>

The Future whose result we want to return.

exceptionClassClass<E>

Exceptions of this type will be rethrown.

Returns
TypeDescription
T

The result of the provided Future.

Exceptions
TypeDescription
E

Thrown If an ExecutionException with a cause of the appropriate type is caught.

<T>quietGet(Future<T> future)

public static T <T>quietGet(Future<T> future)

Return the result of the provided Future, converting all checked exceptions to unchecked exceptions so the caller doesn't have to handle them. If an ExecutionException is thrown the cause is wrapped in a RuntimeException. If an InterruptedException is thrown it is wrapped in a DatastoreFailureException.

Parameter
NameDescription
futureFuture<T>

The Future whose result we want to return.

Returns
TypeDescription
T

The result of the provided Future.

Constructors

FutureHelper()

public FutureHelper()