Module storm

Interface TemplateFunction

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface TemplateFunction
TemplateFunction relies on preview features of the Java platform:
  • TemplateFunction refers to one or more preview APIs: StringTemplate.
Programs can only use TemplateFunction when preview features are enabled.
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.

  • Method Details

    • template

      static StringTemplatePREVIEW template(@Nonnull TemplateFunction function)
      Uses the specified function to generate a string template.
      Parameters:
      function - the function to use for template generation.
      Returns:
      the string template.
    • interpolate

      String interpolate(@Nonnull TemplateFunction.Context context)
      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.