- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
TemplateFunction relies on preview features of the Java platform:
TemplateFunctionrefers to one or more preview APIs:StringTemplate.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Represents a template function.
Template functions are used to implement string interpolation without using Java 21's String Interpolation language feature. Template functions primarily used to support query builders for Kotlin, as Kotlin does not support Java's String Interpolation feature.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceContext object that provides the ability to inject arguments into the string template. -
Method Summary
Modifier and TypeMethodDescriptioninterpolate(TemplateFunction.Context context) Interpolates the template using the given context.static StringTemplatePREVIEWtemplate(TemplateFunction function) Uses the specifiedfunctionto generate a string template.
-
Method Details
-
template
Uses the specifiedfunctionto generate a string template.- Parameters:
function- the function to use for template generation.- Returns:
- the string template.
-
interpolate
Interpolates the template using the given context.- Parameters:
context- the context to use for interpolation.- Returns:
- the string containing intermediary strings as result of argument injection.
-
TemplateFunctionwhen preview features are enabled.