Package gg.jte

Interface CodeResolver


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 Details

    • resolve

      String resolve(String name)
      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 null if no template with this name exists.
    • resolveRequired

      default String resolveRequired(String name) throws TemplateNotFoundException
      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

      long getLastModified(String name)
      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 0L if no template with this name exists. In case this CodeResolver does not support modification times 0L should be returned.
    • resolveAllTemplateNames

      default List<String> resolveAllTemplateNames()
      Resolves all template names this CodeResolver can resolve.
      Returns:
      A list of all existing templates.
      Throws:
      UnsupportedOperationException - in case this operation is not supported by this code resolver
    • exists

      default boolean exists(String name)
      Checks if a template with this name exists.
      Parameters:
      name - The name of the template, e.g. "tag/util/card.jte".
      Returns:
      true if a template with this name exists, otherwise false.