Interface ContextualExecutor

All Superinterfaces:
Executor

public interface ContextualExecutor extends Executor
Facility for contextual execution.
Author:
Paul Ferraro
  • Method Summary

    Modifier and Type
    Method
    Description
    default <T> T
    execute(Callable<T> caller)
    Executes the specified caller with a given context.
    <V1,V2> void
    execute(BiConsumer<V1,V2> consumer, V1 value1, V2 value2)
    Executes the specified runner.
    <V1,V2,R> R
    execute(BiFunction<V1,V2,R> function, V1 value1, V2 value2)
    Executes the specified supplier with a given context.
    <V> void
    execute(Consumer<V> consumer, V value)
    Executes the specified consumer using the specified value.
    <V,R> R
    execute(Function<V,R> function, V value)
    Executes the specified supplier with a given context.
    <T> T
    execute(Supplier<T> supplier)
    Executes the specified supplier with a given context.
    static <C> ContextualExecutor
    Creates a contextual executor from the specified context provider.

    Methods inherited from interface Executor

    execute
  • Method Details

    • execute

      <V> void execute(Consumer<V> consumer, V value)
      Executes the specified consumer using the specified value.
      Type Parameters:
      V - the consumed value type
      Parameters:
      consumer - a consumer
      value - the consumed value
    • execute

      <V1,V2> void execute(BiConsumer<V1,V2> consumer, V1 value1, V2 value2)
      Executes the specified runner.
      Type Parameters:
      V1 - the 1st consumed value type
      V2 - the 2nd consumed value type
      Parameters:
      consumer - a consumer
      value1 - the 1st consumed value
      value2 - the 2nd consumed value
    • execute

      default <T> T execute(Callable<T> caller) throws Exception
      Executes the specified caller with a given context.
      Type Parameters:
      T - the return type
      Parameters:
      caller - a callable task
      Returns:
      the result of the caller
      Throws:
      Exception - if execution fails
    • execute

      <T> T execute(Supplier<T> supplier)
      Executes the specified supplier with a given context.
      Type Parameters:
      T - the return type
      Parameters:
      supplier - a supplier task
      Returns:
      the result of the supplier
    • execute

      <V,R> R execute(Function<V,R> function, V value)
      Executes the specified supplier with a given context.
      Type Parameters:
      V - the function parameter type
      R - the function return type
      Parameters:
      function - a function to apply
      value - the function parameter
      Returns:
      the result of the function
    • execute

      <V1,V2,R> R execute(BiFunction<V1,V2,R> function, V1 value1, V2 value2)
      Executes the specified supplier with a given context.
      Type Parameters:
      V1 - the 1st function parameter type
      V2 - the 2nd function parameter type
      R - the function return type
      Parameters:
      function - a function to apply
      value1 - the 1st function parameter
      value2 - the 2nd function parameter
      Returns:
      the result of the function
    • withContextProvider

      static <C> ContextualExecutor withContextProvider(Supplier<Context<C>> provider)
      Creates a contextual executor from the specified context provider.
      Type Parameters:
      C - the context type
      Parameters:
      provider - a supplier of a context
      Returns:
      a contextual executor using the specified context provider.