Class IContextExtensions
- java.lang.Object
-
- nz.net.ultraq.thymeleaf.layoutdialect.context.extensions.IContextExtensions
-
-
Constructor Summary
Constructors Constructor Description IContextExtensions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectgetAt(IContext self, String name)Enables use of thevalue = context[key]syntax over the context object, is a synonym for thegetVariablemethod.static <T> TgetOrCreate(IContext self, String key, Supplier<T> closure)Retrieves an item from the context, or creates one on the context if it doesn't yet exist.static StringgetPrefixForDialect(IContext self, Class<? extends IProcessorDialect> dialectClass)Returns the configured prefix for the given dialect.static voidputAt(IContext self, String name, Object value)Enables use of thecontext[key] = valuesyntax over the context object, is a synonym for thesetVariablemethod.
-
-
-
Method Detail
-
getAt
public static Object getAt(IContext self, String name)
Enables use of thevalue = context[key]syntax over the context object, is a synonym for thegetVariablemethod.- Parameters:
self-name- Name of the variable on the context to retrieve.- Returns:
- The variable value, or
nullif the variable isn't mapped to anything on the context.
-
getOrCreate
public static <T> T getOrCreate(@Nonnull IContext self, @Nonnull String key, Supplier<T> closure)
Retrieves an item from the context, or creates one on the context if it doesn't yet exist.- Type Parameters:
T-- Parameters:
self-key-closure-- Returns:
- The item cached on the context through the given key, or first constructed through the closure.
-
getPrefixForDialect
public static String getPrefixForDialect(@Nonnull IContext self, Class<? extends IProcessorDialect> dialectClass)
Returns the configured prefix for the given dialect. If the dialect prefix has not been configured.- Parameters:
self-dialectClass-- Returns:
- The configured prefix for the dialect, or
nullif the dialect being queried hasn't been configured.
-
-