org.springframework.util.concurrent

Class FutureAdapter<T,S>

  • java.lang.Object
    • org.springframework.util.concurrent.FutureAdapter<T,S>
  • Type Parameters:
    T - the type of this Future
    S - the type of the adaptee's Future
    All Implemented Interfaces:
    java.util.concurrent.Future<T>
    Direct Known Subclasses:
    ListenableFutureAdapter


    public abstract class FutureAdapter<T,S>
    extends java.lang.Object
    implements java.util.concurrent.Future<T>
    Abstract class that adapts a Future parameterized over S into a Future parameterized over T. All methods are delegated to the adaptee, where get() and get(long, TimeUnit) call adapt(Object) on the adaptee's result.
    Since:
    4.0
    Author:
    Arjen Poutsma
    • Constructor Summary

      Constructors 
      Modifier Constructor and Description
      protected FutureAdapter(java.util.concurrent.Future<S> adaptee)
      Constructs a new FutureAdapter with the given adaptee.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      protected abstract T adapt(S adapteeResult)
      Adapts the given adaptee's result into T.
      boolean cancel(boolean mayInterruptIfRunning) 
      T get() 
      T get(long timeout, java.util.concurrent.TimeUnit unit) 
      protected java.util.concurrent.Future<S> getAdaptee()
      Returns the adaptee.
      boolean isCancelled() 
      boolean isDone() 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FutureAdapter

        protected FutureAdapter(java.util.concurrent.Future<S> adaptee)
        Constructs a new FutureAdapter with the given adaptee.
        Parameters:
        adaptee - the future to delegate to
    • Method Detail

      • getAdaptee

        protected java.util.concurrent.Future<S> getAdaptee()
        Returns the adaptee.
      • cancel

        public boolean cancel(boolean mayInterruptIfRunning)
        Specified by:
        cancel in interface java.util.concurrent.Future<T>
      • isCancelled

        public boolean isCancelled()
        Specified by:
        isCancelled in interface java.util.concurrent.Future<T>
      • isDone

        public boolean isDone()
        Specified by:
        isDone in interface java.util.concurrent.Future<T>
      • get

        @Nullable
        public T get()
                        throws java.lang.InterruptedException,
                               java.util.concurrent.ExecutionException
        Specified by:
        get in interface java.util.concurrent.Future<T>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • get

        @Nullable
        public T get(long timeout,
                               java.util.concurrent.TimeUnit unit)
                        throws java.lang.InterruptedException,
                               java.util.concurrent.ExecutionException,
                               java.util.concurrent.TimeoutException
        Specified by:
        get in interface java.util.concurrent.Future<T>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.util.concurrent.TimeoutException
      • adapt

        @Nullable
        protected abstract T adapt(S adapteeResult)
                                      throws java.util.concurrent.ExecutionException
        Adapts the given adaptee's result into T.
        Returns:
        the adapted result
        Throws:
        java.util.concurrent.ExecutionException