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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> BiConsumer<? super T, ? super Throwable> completeInstrumentationCtxCF(InstrumentationContext<T> instrumentationContext) static <T> @NonNull InstrumentationContext<T> nonNullCtx(InstrumentationContext<T> nullableContext) This creates a no-opInstrumentationContextif the one pass in is nullstatic <T> InstrumentationContext<T> noOp()A context that does nothingvoidonCompleted(T result, Throwable t) This is invoked when the instrumentation step is fully completedvoidThis is invoked when the instrumentation step is initially dispatchedstatic <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.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.
-
Constructor Details
-
SimpleInstrumentationContext
public SimpleInstrumentationContext()
-
-
Method Details
-
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-opInstrumentationContextif the one pass in is null- Type Parameters:
T- for two- Parameters:
nullableContext- aInstrumentationContextthat can be null- Returns:
- a non null
InstrumentationContextthat maybe a no-op
-
onDispatched
public void onDispatched()Description copied from interface:InstrumentationContextThis is invoked when the instrumentation step is initially dispatched- Specified by:
onDispatchedin interfaceInstrumentationContext<T>
-
onCompleted
Description copied from interface:InstrumentationContextThis is invoked when the instrumentation step is fully completed- Specified by:
onCompletedin interfaceInstrumentationContext<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
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
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)
-