Interface Callable<T>

Type Parameters:
T - the result type
All Superinterfaces:
Callable<T>

public interface Callable<T> extends Callable<T>
An enhanced callable.
Author:
Paul Ferraro
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Callable<?>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> Callable<T>
    Returns a callable that returns null.
    static <T> Callable<T>
    exceptional(Supplier<? extends Exception> exceptionProvider)
    Returns a callable that throws the provided exception.
    static <T> Callable<T>
    get(Supplier<T> supplier)
    Returns a callable that delegates to the specified supplier.
    default <R> Callable<R>
    map(Function<T,R> mapper)
    Returns a callable whose result is mapped by the specified function.
    static <T> Callable<T>
    of(T value)
    Returns a callable that returns the specified value.
    static <T> Callable<T>
    run(Runnable runner)
    Returns a callable that runs the specified runner and returns null.

    Methods inherited from interface java.util.concurrent.Callable

    call
  • Field Details

  • Method Details

    • map

      default <R> Callable<R> map(Function<T,R> mapper)
      Returns a callable whose result is mapped by the specified function.
      Type Parameters:
      R - the mapped result type
      Parameters:
      mapper - a mapping function
      Returns:
      a callable whose result is mapped by the specified function.
    • empty

      static <T> Callable<T> empty()
      Returns a callable that returns null.
      Parameters:
      value - the result value
      Returns:
      a callable that returns null.
    • run

      static <T> Callable<T> run(Runnable runner)
      Returns a callable that runs the specified runner and returns null.
      Parameters:
      runner - a runner
      Returns:
      a callable that runs the specified runner and returns null.
    • get

      static <T> Callable<T> get(Supplier<T> supplier)
      Returns a callable that delegates to the specified supplier.
      Parameters:
      supplier - a supplier
      Returns:
      the result of the specified supplier.
    • of

      static <T> Callable<T> of(T value)
      Returns a callable that returns the specified value.
      Parameters:
      value - the result value
      Returns:
      a callable that returns the specified value.
    • exceptional

      static <T> Callable<T> exceptional(Supplier<? extends Exception> exceptionProvider)
      Returns a callable that throws the provided exception.
      Parameters:
      exceptionProvider - a provider of an exception
      Returns:
      a callable that throws the provided exception.