public interface CodeResolver
Responsible for resolving template code.
Used by the
TemplateEngine to transfer templates into native Java/Kotlin code.
When running in production with precompiled templates, no CodeResolver is required.-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanChecks if a template with this name exists.longgetLastModified(String name) Resolves the last modification time of a template.Resolves the code of a template.Resolves all template names thisCodeResolvercan resolve.default StringresolveRequired(String name) Resolves the code of a template, which is required to exist.
-
Method Details
-
resolve
Resolves the code of a template.- Parameters:
name- The name of the template, e.g."tag/util/card.jte".- Returns:
- The code of the resolved template, or
nullif no template with this name exists.
-
resolveRequired
Resolves the code of a template, which is required to exist.- Parameters:
name- The name of the template, e.g."tag/util/card.jte".- Returns:
- The code of the resolved template, this is never
null. - Throws:
TemplateNotFoundException- if no template with this name exists. Implementations that have better knowledge why the loading failed, are expected to override this method and provide information about the problem in the thrown exception message.
-
getLastModified
Resolves the last modification time of a template.- Parameters:
name- The name of the template, e.g."tag/util/card.jte".- Returns:
- The last modification time of this template in milliseconds, or
0Lif no template with this name exists. In case thisCodeResolverdoes not support modification times0Lshould be returned.
-
resolveAllTemplateNames
Resolves all template names thisCodeResolvercan resolve.- Returns:
- A list of all existing templates.
- Throws:
UnsupportedOperationException- in case this operation is not supported by this code resolver
-
exists
Checks if a template with this name exists.- Parameters:
name- The name of the template, e.g."tag/util/card.jte".- Returns:
trueif a template with this name exists, otherwise false.
-