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 Object
getAt(IContext self, String name)
Enables use of thevalue = context[key]
syntax over the context object, is a synonym for thegetVariable
method.static <T> T
getOrCreate(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 String
getPrefixForDialect(IContext self, Class<? extends IProcessorDialect> dialectClass)
Returns the configured prefix for the given dialect.static void
putAt(IContext self, String name, Object value)
Enables use of thecontext[key] = value
syntax over the context object, is a synonym for thesetVariable
method.
-
-
-
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 thegetVariable
method.- Parameters:
self
-name
- Name of the variable on the context to retrieve.- Returns:
- The variable value, or
null
if 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
null
if the dialect being queried hasn't been configured.
-
-