Class ContextUtility

java.lang.Object
com.broadleafcommerce.data.tracking.core.context.ContextUtility

public final class ContextUtility extends Object
Utility class for temporarily setting several values on ContextInfo for the scope of a block of code embodied in a Supplier.
Author:
Jeff Fischer
  • Field Details

    • ACTIVE_DATE_FILTER_CONTEXT

      public static final ThreadLocal<Boolean> ACTIVE_DATE_FILTER_CONTEXT
    • ACTIVE_FLAG_FILTER_CONTEXT

      public static final ThreadLocal<Boolean> ACTIVE_FLAG_FILTER_CONTEXT
  • Method Details

    • forceDoWithoutActiveCheck

      public static <P> P forceDoWithoutActiveCheck(Supplier<P> function, ContextInfo contextInfo)
      Force active date checking to be disabled during this flow. This value will be immutable for the duration of this call.
      Type Parameters:
      P - The result type
      Parameters:
      function - The code to process with active date handling disabled
      contextInfo - The current context information
      Returns:
      The result of the call
    • doWithoutActiveCheck

      public static <P> P doWithoutActiveCheck(Supplier<P> function, ContextInfo contextInfo)
      Similar to forceDoWithoutActiveCheck(Supplier, ContextInfo), except the state is not forced, nor is it immutable for the duration of the call.
      Type Parameters:
      P - The result type
      Parameters:
      function - The code to process with active date handling disabled
      contextInfo - The current context information
      Returns:
      The result of the call
    • doWithoutCache

      public static <P> P doWithoutCache(Supplier<P> function)
      Execute this flow with cache disabled.
      Type Parameters:
      P - he result type
      Parameters:
      function - The code to process with cache handling disabled
      Returns:
      The result of the call
    • forceDoWithActiveCheck

      public static <P> P forceDoWithActiveCheck(Supplier<P> function, ContextInfo contextInfo)
      Force active date checking to be enabled during this flow. This value will be immutable for the duration of this call.
      Type Parameters:
      P - The result type
      Parameters:
      function - The code to process with active date handling enabled
      contextInfo - The current context information
      Returns:
      The result of the call
    • doWithActiveCheck

      public static <P> P doWithActiveCheck(Supplier<P> function, ContextInfo contextInfo)
      Similar to forceDoWithActiveCheck(Supplier, ContextInfo), except the state is not forced, nor is it immutable for the duration of the call.
      Type Parameters:
      P - The result type
      Parameters:
      function - The code to process with active date handling enabled
      contextInfo - The current context information
      Returns:
      The result of the call