Package org.pipecraft.infra.concurrent
Class ImmediateFuture<V,E extends Exception>
- java.lang.Object
-
- org.pipecraft.infra.concurrent.AbstractCheckedFuture<V,E>
-
- org.pipecraft.infra.concurrent.ImmediateFuture<V,E>
-
- Type Parameters:
V- The future's value data type
- All Implemented Interfaces:
com.google.common.util.concurrent.ListenableFuture<V>,Future<V>,CheckedFuture<V,E>
public class ImmediateFuture<V,E extends Exception> extends AbstractCheckedFuture<V,E>
A checked listenable future that returns a predefined value or throws a predifined exception.- Author:
- Eyal Schneider
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Emap(Exception e)Maps a checked exception originating from the underlying computation into the standard exception type E.static <V,E extends Exception>
CheckedFuture<V,E>ofError(E exception)static <V,E extends Exception>
CheckedFuture<V,E>ofValue(V value)-
Methods inherited from class org.pipecraft.infra.concurrent.AbstractCheckedFuture
addListener, cancel, checkedGet, checkedGet, get, get, isCancelled, isDone
-
-
-
-
Method Detail
-
map
protected E map(Exception e)
Description copied from class:AbstractCheckedFutureMaps a checked exception originating from the underlying computation into the standard exception type E. In most cases when e is of type RuntimeException, it's recommended to simply throw it here, to avoid hiding a severe error or presenting it as a legitimate error.- Specified by:
mapin classAbstractCheckedFuture<V,E extends Exception>- Parameters:
e- The original exception- Returns:
- The mapped exception of type E
-
ofValue
public static <V,E extends Exception> CheckedFuture<V,E> ofValue(V value)
- Parameters:
value- A value to be returned by the future- Returns:
- The listenable checked future programmed with the given value
-
ofError
public static <V,E extends Exception> CheckedFuture<V,E> ofError(E exception)
- Parameters:
exception- The exception to throw- Returns:
- The listenable checked future programmed with the given exception
-
-