Class EvalHooksRunner<T>

java.lang.Object
com.devcycle.sdk.server.common.model.EvalHooksRunner<T>

public class EvalHooksRunner<T> extends Object
A class that manages evaluation hooks for the DevCycle SDK. Provides functionality to add and clear hooks, storing them in an array.
  • Constructor Details

    • EvalHooksRunner

      public EvalHooksRunner(List<EvalHook<T>> hooks)
      Default constructor initializes an empty list of hooks.
    • EvalHooksRunner

      public EvalHooksRunner()
  • Method Details

    • addHook

      public void addHook(EvalHook<T> hook)
      Adds a single hook to the collection.
      Parameters:
      hook - The hook to add
    • clearHooks

      public void clearHooks()
      Clears all hooks from the collection.
    • getHooks

      public List<EvalHook<T>> getHooks()
    • executeBefore

      public <T> HookContext<T> executeBefore(ArrayList<EvalHook<T>> hooks, HookContext<T> context)
      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)
      Runs all after hooks in reverse order.
      Type Parameters:
      T - The type of the variable value
      Parameters:
      context - The context to pass to the hooks
      variable - The variable result to pass to the hooks
    • executeError

      public void executeError(ArrayList<EvalHook<T>> hooks, HookContext<T> context, Throwable error)
      Runs all error hooks in reverse order.
      Type Parameters:
      T - The type of the variable value
      Parameters:
      context - The context to pass to the hooks
      error - The error that occurred
    • executeFinally

      public void executeFinally(ArrayList<EvalHook<T>> hooks, HookContext<T> context, Optional<Variable<T>> variable)
      Runs all finally hooks in reverse order.
      Parameters:
      context - The context to pass to the hooks
      variable - The variable result to pass to the hooks (may be null)