Class ImmediateFuture<V,​E extends Exception>

  • 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 Detail

      • map

        protected E map​(Exception e)
        Description copied from class: AbstractCheckedFuture
        Maps 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:
        map in class AbstractCheckedFuture<V,​E extends Exception>
        Parameters:
        e - The original exception
        Returns:
        The mapped exception of type E
      • ofValue

        public static <V,​E extends ExceptionCheckedFuture<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 ExceptionCheckedFuture<V,​E> ofError​(E exception)
        Parameters:
        exception - The exception to throw
        Returns:
        The listenable checked future programmed with the given exception