Class ContextSnapshot

java.lang.Object
it.tidalwave.util.spi.ContextSnapshot

public class ContextSnapshot extends Object
A facility that takes a snapshot of the contexts that are current at creation time and make them available later.
Author:
Fabrizio Giudici
  • Constructor Details Link icon

    • ContextSnapshot Link icon

      public ContextSnapshot(@Nonnull Object owner)
      Creates a new instance and samples the currently available contexts.
      Parameters:
      owner - the owner
  • Method Details Link icon

    • getContexts Link icon

      @Nonnull public List<Object> getContexts()
      Returns the previously sampled contexts.
      Returns:
      the contexts
    • runWithContexts Link icon

      public <V, T extends Throwable> V runWithContexts(@Nonnull Task<V,T> task) throws T
      Runs a Task associated with the sampled contexts.
      Type Parameters:
      V - the type of the result value
      T - the type of the exception
      Parameters:
      task - the task
      Returns:
      the value produced by the task
      Throws:
      T - the exception(s) thrown by the task
    • toString Link icon

      @Nonnull public String toString()
      Overrides:
      toString in class Object