Interface TemplateInfo

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 Templates.

Author:
agentgt
  • Method Details

    • templateName

      The logical name of the template which maybe different than templatePath().
      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 via config 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

      default String normalizePath()
      Normalizes the path to used by ClassLoader.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 use templateSource().
      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

      The template content type is the class annotated with JStacheContentType 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. See Escaper.of(Function).
      Returns:
      the escaper.
      See Also:
      API Note
      While the return signature is Function the function is often an Escaper but does not have to be.
    • templateFormatter

      The base formatter to be used on the template. See Formatter.of(Function).
      Returns:
      the formatter.
      See Also:
      API Note
      While the return signature is Function the function is often a Formatter but does not have to be.
    • supportsType

      boolean supportsType(Class<?> type)
      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

      default long 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

      default String description()
      Utility method similar to toString that describes the template meta data.
      Returns:
      description of the template.