- All Known Subinterfaces:
Template<T>
- All Known Implementing Classes:
HelloModelView
,HelloModelView
,MessagePageRenderer
,MessagePageRenderer
public interface TemplateInfo
Template meta data like its location, formatters, escapers and or its contents.
This data is usually available on generated Template
s.
- Author:
- agentgt
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Symbols representing where the template was retrieved from. -
Method Summary
Modifier and TypeMethodDescriptiondefault String
Utility method similar to toString that describes the template meta data.default long
The last loaded time if applicable.default String
Normalizes the path to used byClassLoader.getResource(String)
.boolean
supportsType
(Class<?> type) Checks to see if a template supports the model class.Class<?>
The template content type is the class annotated withJStacheContentType
which also describes the escaper to be used.The escaper to be used on the template.The base formatter to be used on the template.The logical name of the template which maybe different thantemplatePath()
.If the template is a classpath resource file this will return the location that was originally resolved viaconfig resolution
.default TemplateInfo.TemplateSource
Where the template contents were retrieved from.default String
The raw contents of the template.
-
Method Details
-
templateName
The logical name of the template which maybe different thantemplatePath()
.- Returns:
- logical name of template. Never null.
-
templatePath
If the template is a classpath resource file this will return the location that was originally resolved viaconfig resolution
.- Returns:
- the location of the template or empty if the template is inlined.
- See Also:
- API Note
- since the return is the original path resolved by the annotation processor
it may return a path with a starting "/" and thus it is recommend you call
normalizePath()
if you plan on loading the resource.
-
normalizePath
Normalizes the path to used byClassLoader.getResource(String)
. If the templatePath starts with a "/" it is stripped.- Returns:
- normalized path
-
templateString
The raw contents of the template. Useful if the template is inline. To determine if the template is actually inline usetemplateSource()
.- Returns:
- the raw contents of the template never null.
- See Also:
- API Note
- An empty or blank template string maybe a valid inline template and does not mean it is not inline.
-
templateContentType
Class<?> templateContentType()The template content type is the class annotated withJStacheContentType
which also describes the escaper to be used.- Returns:
- the template content type.
- API Note
- The class returned must be annotated with
JStacheContentType
.
-
templateEscaper
The escaper to be used on the template. SeeEscaper.of(Function)
. -
templateFormatter
Function<@Nullable Object,String> templateFormatter()The base formatter to be used on the template. SeeFormatter.of(Function)
. -
supportsType
Checks to see if a template supports the model class.- Parameters:
type
- the class of the model.- Returns:
- if this renderer supports the class.
-
templateSource
Where the template contents were retrieved from.- Returns:
- an enum never null.
-
lastLoaded
The last loaded time if applicable. For statically compiled templates this will always be a negative number. For dynamically loaded templates this more likely will return a non negative number indicating some hint of when the template was last modified or loaded.- Returns:
- the last modified or negative if not applicable
-
description
Utility method similar to toString that describes the template meta data.- Returns:
- description of the template.
-