Interface Contextualizer


public interface Contextualizer
Facility for creating contextual tasks.
Author:
Paul Ferraro
  • Field Details

    • NONE

      static final Contextualizer NONE
      A pass-through contextualizer.
  • Method Details

    • contextualize

      Runnable contextualize(Runnable runner)
      Decorates the specified runner with a given context.
      Parameters:
      runner - a runnable task
      Returns:
      a contextual runner
    • contextualize

      <T> Callable<T> contextualize(Callable<T> caller)
      Decorates the specified caller with a given context.
      Type Parameters:
      T - the return type
      Parameters:
      caller - a callable task
      Returns:
      a contextual caller
    • contextualize

      <T> Supplier<T> contextualize(Supplier<T> supplier)
      Decorates the specified supplier with a given context.
      Type Parameters:
      T - the return type
      Parameters:
      supplier - a supplier task
      Returns:
      a contextual supplier
    • contextualize

      <V> Consumer<V> contextualize(Consumer<V> consumer)
      Decorates the specified consumer with a given context.
      Type Parameters:
      V - the consumed value type
      Parameters:
      consumer - a consumer
      Returns:
      a contextual consumer
    • contextualize

      <V1,V2> BiConsumer<V1,V2> contextualize(BiConsumer<V1,V2> consumer)
      Decorates the specified consumer with a given context.
      Type Parameters:
      V1 - the 1st consumed value type
      V2 - the 2nd consumed value type
      Parameters:
      consumer - a consumer
      Returns:
      a contextual consumer
    • contextualize

      <V,R> Function<V,R> contextualize(Function<V,R> function)
      Decorates the specified function with a given context.
      Type Parameters:
      V - the function parameter type
      R - the function return type
      Parameters:
      function - a function
      Returns:
      a contextual function
    • contextualize

      <V1,V2,R> BiFunction<V1,V2,R> contextualize(BiFunction<V1,V2,R> function)
      Decorates the specified function 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
      Returns:
      a contextual function
    • withContextProvider

      static <C> Contextualizer withContextProvider(Supplier<Context<C>> provider)
      Creates a contextualizer from the specified context provider.
      Type Parameters:
      C - the context type
      Parameters:
      provider - a supplier of a context
      Returns:
      a contextualizer using the specified context provider.
    • composite

      static Contextualizer composite(Iterable<Contextualizer> contextualizers)
      Creates a composite contextualizer from multiple contextualizers.
      Parameters:
      contextualizers - a list of contextualizers.
      Returns:
      a composite contextualizer