Class SimpleInstrumentationContext<T>

java.lang.Object
graphql.execution.instrumentation.SimpleInstrumentationContext<T>
All Implemented Interfaces:
InstrumentationContext<T>

@PublicApi public class SimpleInstrumentationContext<T> extends Object implements InstrumentationContext<T>
A simple implementation of InstrumentationContext
  • Constructor Details

    • SimpleInstrumentationContext

      public SimpleInstrumentationContext()
  • Method Details

    • noOp

      public static <T> InstrumentationContext<T> noOp()
      A context that does nothing
      Type Parameters:
      T - the type needed
      Returns:
      a context that does nothing
    • nonNullCtx

      public static <T> @NonNull InstrumentationContext<T> nonNullCtx(InstrumentationContext<T> nullableContext)
      This creates a no-op InstrumentationContext if the one pass in is null
      Type Parameters:
      T - for two
      Parameters:
      nullableContext - a InstrumentationContext that can be null
      Returns:
      a non null InstrumentationContext that maybe a no-op
    • onDispatched

      public void onDispatched()
      Description copied from interface: InstrumentationContext
      This is invoked when the instrumentation step is initially dispatched
      Specified by:
      onDispatched in interface InstrumentationContext<T>
    • onCompleted

      public void onCompleted(T result, Throwable t)
      Description copied from interface: InstrumentationContext
      This is invoked when the instrumentation step is fully completed
      Specified by:
      onCompleted in interface InstrumentationContext<T>
      Parameters:
      result - the result of the step (which may be null)
      t - this exception will be non null if an exception was thrown during the step
    • whenDispatched

      public static <U> SimpleInstrumentationContext<U> whenDispatched(Runnable codeToRun)
      Allows for the more fluent away to return an instrumentation context that runs the specified code on instrumentation step dispatch.
      Type Parameters:
      U - the generic type
      Parameters:
      codeToRun - the code to run on dispatch
      Returns:
      an instrumentation context
    • whenCompleted

      public static <U> SimpleInstrumentationContext<U> whenCompleted(BiConsumer<U,Throwable> codeToRun)
      Allows for the more fluent away to return an instrumentation context that runs the specified code on instrumentation step completion.
      Type Parameters:
      U - the generic type
      Parameters:
      codeToRun - the code to run on completion
      Returns:
      an instrumentation context
    • completeInstrumentationCtxCF

      public static <T> BiConsumer<? super T,? super Throwable> completeInstrumentationCtxCF(InstrumentationContext<T> instrumentationContext)