Class EvalHooksRunner<T>
java.lang.Object
com.devcycle.sdk.server.common.model.EvalHooksRunner<T>
A class that manages evaluation hooks for the DevCycle SDK.
Provides functionality to add and clear hooks, storing them in an array.
-
Constructor Summary
ConstructorsConstructorDescriptionEvalHooksRunner(List<EvalHook<T>> hooks) Default constructor initializes an empty list of hooks. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a single hook to the collection.voidClears all hooks from the collection.voidexecuteAfter(ArrayList<EvalHook<T>> hooks, HookContext<T> context, Variable<T> variable, VariableMetadata variableMetadata) Runs all after hooks in reverse order.<T> HookContext<T>executeBefore(ArrayList<EvalHook<T>> hooks, HookContext<T> context) Runs all before hooks in order.voidexecuteError(ArrayList<EvalHook<T>> hooks, HookContext<T> context, Throwable error) Runs all error hooks in reverse order.voidexecuteFinally(ArrayList<EvalHook<T>> hooks, HookContext<T> context, Optional<Variable<T>> variable, VariableMetadata variableMetadata) Runs all finally hooks in reverse order.getHooks()
-
Constructor Details
-
EvalHooksRunner
Default constructor initializes an empty list of hooks. -
EvalHooksRunner
public EvalHooksRunner()
-
-
Method Details
-
addHook
Adds a single hook to the collection.- Parameters:
hook- The hook to add
-
clearHooks
public void clearHooks()Clears all hooks from the collection. -
getHooks
-
executeBefore
Runs all before hooks in order.- Type Parameters:
T- The type of the variable value- Parameters:
context- The context to pass to the hooks- Returns:
- The potentially modified context
-
executeAfter
public void executeAfter(ArrayList<EvalHook<T>> hooks, HookContext<T> context, Variable<T> variable, VariableMetadata variableMetadata) Runs all after hooks in reverse order.- Type Parameters:
T- The type of the variable value- Parameters:
context- The context to pass to the hooksvariable- The variable result to pass to the hooks
-
executeError
Runs all error hooks in reverse order.- Type Parameters:
T- The type of the variable value- Parameters:
context- The context to pass to the hookserror- The error that occurred
-
executeFinally
public void executeFinally(ArrayList<EvalHook<T>> hooks, HookContext<T> context, Optional<Variable<T>> variable, VariableMetadata variableMetadata) Runs all finally hooks in reverse order.- Parameters:
context- The context to pass to the hooksvariable- The variable result to pass to the hooks (may be null)
-