Class RunnableCallableAdapter<T>

  • Type Parameters:
    T - Type of result returned
    All Implemented Interfaces:
    java.util.concurrent.Callable<T>, RunnableContainer

    public class RunnableCallableAdapter<T>
    extends java.lang.Object
    implements java.util.concurrent.Callable<T>, RunnableContainer
    Converts a Runnable with a result into a Callable. This is similar to Executors.callable(Runnable, Object), except this implementation also implements the RunnableContainer interface.
    Since:
    4.3.0
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.concurrent.Callable<T> adapt​(java.lang.Runnable runnable, T result)
      Adapt a Runnable and result into a Callable.
      T call()  
      java.lang.Runnable getContainedRunnable()
      Call to get the contained runnable within the wrapper.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • adapt

        public static <T> java.util.concurrent.Callable<T> adapt​(java.lang.Runnable runnable,
                                                                 T result)
        Adapt a Runnable and result into a Callable. The returned callable will invoke Runnable.run() then return the result provided to this function.
        Type Parameters:
        T - Type of result to be returned from provided Callable
        Parameters:
        runnable - Runnable to be invoked when this adapter is ran
        result - Result to return from Callable or null
        Returns:
        A Callable instance for invocation
      • getContainedRunnable

        public java.lang.Runnable getContainedRunnable()
        Description copied from interface: RunnableContainer
        Call to get the contained runnable within the wrapper.
        Specified by:
        getContainedRunnable in interface RunnableContainer
        Returns:
        runnable contained, or null if none is contained
      • call

        public T call()
        Specified by:
        call in interface java.util.concurrent.Callable<T>