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 onContextInfo
for the scope of a block of code embodied in aSupplier
.- Author:
- Jeff Fischer
-
-
Field Summary
Fields Modifier and Type Field Description static ThreadLocal<Boolean>
ACTIVE_DATE_FILTER_CONTEXT
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <P> P
doWithActiveCheck(Supplier<P> function, ContextInfo contextInfo)
Similar toforceDoWithActiveCheck(Supplier, ContextInfo)
, except the state is not forced, nor is it immutable for the duration of the call.static <P> P
doWithoutActiveCheck(Supplier<P> function, ContextInfo contextInfo)
Similar toforceDoWithoutActiveCheck(Supplier, ContextInfo)
, except the state is not forced, nor is it immutable for the duration of the call.static <P> P
doWithoutCache(Supplier<P> function)
Execute this flow with cache disabled.static <P> P
forceDoWithActiveCheck(Supplier<P> function, ContextInfo contextInfo)
Force active date checking to be enabled during this flow.static <P> P
forceDoWithoutActiveCheck(Supplier<P> function, ContextInfo contextInfo)
Force active date checking to be disabled during this flow.
-
-
-
Field Detail
-
ACTIVE_DATE_FILTER_CONTEXT
public static final ThreadLocal<Boolean> ACTIVE_DATE_FILTER_CONTEXT
-
-
Method Detail
-
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 disabledcontextInfo
- The current context information- Returns:
- The result of the call
-
doWithoutActiveCheck
public static <P> P doWithoutActiveCheck(Supplier<P> function, ContextInfo contextInfo)
Similar toforceDoWithoutActiveCheck(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 disabledcontextInfo
- 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 enabledcontextInfo
- The current context information- Returns:
- The result of the call
-
doWithActiveCheck
public static <P> P doWithActiveCheck(Supplier<P> function, ContextInfo contextInfo)
Similar toforceDoWithActiveCheck(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 enabledcontextInfo
- The current context information- Returns:
- The result of the call
-
-