Package org.threadly.concurrent
Class RunnableCallableAdapter<T>
- java.lang.Object
-
- org.threadly.concurrent.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 aRunnable
with a result into aCallable
. This is similar toExecutors.callable(Runnable, Object)
, except this implementation also implements theRunnableContainer
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 aRunnable
and result into aCallable
.T
call()
java.lang.Runnable
getContainedRunnable()
Call to get the contained runnable within the wrapper.
-
-
-
Method Detail
-
adapt
public static <T> java.util.concurrent.Callable<T> adapt(java.lang.Runnable runnable, T result)
Adapt aRunnable
and result into aCallable
. The returned callable will invokeRunnable.run()
then return the result provided to this function.- Type Parameters:
T
- Type of result to be returned from providedCallable
- Parameters:
runnable
- Runnable to be invoked when this adapter is ranresult
- Result to return from Callable ornull
- 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 interfaceRunnableContainer
- Returns:
- runnable contained, or
null
if none is contained
-
-