Package org.jdbi.v3.core.statement
Interface TemplateEngine
-
- All Known Subinterfaces:
TemplateEngine.Parsing
- All Known Implementing Classes:
DefinedAttributeTemplateEngine,FreemarkerEngine,MessageFormatTemplateEngine,NoTemplateEngine,StringSubstitutorTemplateEngine,StringTemplateEngine
- 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 TemplateEngineRenders an SQL statement from a template. Note for implementors: define a suitable public constructor for SqlObject'sUseTemplateEngineannotation, and/or create your own custom annotation in case yourTemplateEnginehas configuration parameters! Suitable constructors are the no-arg constructor, one that takes aClass, and one that takes both aClassand aMethod.- See Also:
DefinedAttributeTemplateEngine
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceTemplateEngine.Parsing
-
Field Summary
Fields Modifier and Type Field Description static TemplateEngineNOPConvenience constant that returns the input template.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.Optional<java.util.function.Function<StatementContext,java.lang.String>>parse(java.lang.String template, ConfigRegistry config)Parse a SQL template and return a parsed representation ready to apply to a statement.java.lang.Stringrender(java.lang.String template, StatementContext ctx)Renders an SQL statement from the given template, using the statement context as needed.
-
-
-
Field Detail
-
NOP
static final TemplateEngine NOP
Convenience constant that returns the input template.
-
-
Method Detail
-
render
java.lang.String render(java.lang.String template, StatementContext ctx)Renders an SQL statement from the given template, using the statement context as needed.- Parameters:
template- The SQL to rewritectx- The statement context for the statement being executed- Returns:
- something which can provide the actual SQL to prepare a statement from and which can bind the correct arguments to that prepared statement
-
parse
@Beta default java.util.Optional<java.util.function.Function<StatementContext,java.lang.String>> parse(java.lang.String template, ConfigRegistry config)
Parse a SQL template and return a parsed representation ready to apply to a statement. This allows the parsed representation to be cached and reused.- Parameters:
template- the sql template to parseconfig- the Jdbi configuration at prepare time- Returns:
- a parsed representation, if available
-
-