public final class FutureCompanion extends Object
Future
. import static javascalautils.FutureCompanion.Future; Future<Integer> resultSuccess = Future.(() -> 9 / 3); // The Future will at some point contain: Success(3) Future<Integer> resultFailure = Future.(() -> 9 / 0); // The Future will at some point contain: Failure(ArithmeticException)
Modifier and Type | Method and Description |
---|---|
static <T> Future<T> |
Future(ThrowableFunction0<T> function)
Allows for easy creation of asynchronous computations that will be executed in the future.
|
public static <T> Future<T> Future(ThrowableFunction0<T> function)
Future.apply(ThrowableFunction0)
. import static javascalautils.concurrent.FutureCompanion.Future; Future<Integer> resultSuccess = Future.(() -> 9 / 3); // The Future will at some point contain: Success(3) Future<Integer> resultFailure = Future.(() -> 9 / 0); // The Future will at some point contain: Failure(ArithmeticException)
T
- The type for the Futurefunction
- The function to render either the value T or raise an exception.Future.apply(ThrowableFunction0)
Copyright © 2015, Peter Nerg Apache License v2.0