Interface Template

All Known Subinterfaces:
Template.Fragment

public interface Template
Represents an immutable template definition.

The workflow is as follows:

  1. Create a new template instance via instance() or any convenient method
  2. Set the model data
  3. Trigger rendering with TemplateInstance.render() or any other convenient methods
  • Method Details

    • instance

      TemplateInstance instance()
      Create a new template instance to configure the model data.
      Returns:
      a new template instance
      See Also:
    • data

      default TemplateInstance data(Object data)
      Parameters:
      data -
      Returns:
      a new template instance
      See Also:
    • data

      default TemplateInstance data(String key, Object data)
      Parameters:
      key -
      data -
      Returns:
      a new template instance
      See Also:
    • data

      default TemplateInstance data(String key1, Object data1, String key2, Object data2)
      Parameters:
      key1 -
      data1 -
      key2 -
      data2 -
      Returns:
      a new template instance
    • data

      default TemplateInstance data(String key1, Object data1, String key2, Object data2, String key3, Object data3)
      Parameters:
      key1 -
      data1 -
      key2 -
      data2 -
      key3 -
      data3 -
      Returns:
      a new template instance
    • data

      default TemplateInstance data(String key1, Object data1, String key2, Object data2, String key3, Object data3, String key4, Object data4)
      Parameters:
      key1 -
      data1 -
      key2 -
      data2 -
      key3 -
      data3 -
      key4 -
      data4 -
      Returns:
      a new template instance
    • data

      default TemplateInstance data(String key1, Object data1, String key2, Object data2, String key3, Object data3, String key4, Object data4, String key5, Object data5)
      Parameters:
      key1 -
      data1 -
      key2 -
      data2 -
      key3 -
      data3 -
      key4 -
      data4 -
      key5 -
      data5 -
      Returns:
      a new template instance
    • render

      default String render(Object data)
    • render

      default String render()
    • getExpressions

      List<Expression> getExpressions()
      If invoked upon a fragment instance then delegate to the defining template.
      Returns:
      an immutable list of expressions used in the template
    • findExpression

      Expression findExpression(Predicate<Expression> predicate)
      If invoked upon a fragment instance then delegate to the defining template.
      Parameters:
      predicate -
      Returns:
      the first expression matching the given predicate or null if no such expression is used in the template
    • getGeneratedId

      String getGeneratedId()
      The id is unique for the engine instance.
      Returns:
      the generated id
    • getId

      String getId()
      An identifier used to obtain the template from the engine.
      Returns:
      the identifier
      See Also:
    • getVariant

      Optional<Variant> getVariant()
      If invoked upon a fragment instance then delegate to the defining template.
      Returns:
      the template variant
    • getParameterDeclarations

      List<ParameterDeclaration> getParameterDeclarations()
      Returns all type parameter declarations of the template, including the declarations added by a ParserHook.

      If invoked upon a fragment instance then delegate to the defining template.

      Returns:
      an immutable list of all type parameter declarations defined in the template
    • getFragment

      Template.Fragment getFragment(String id)
      Attempts to find the fragment with the specified identifier.

      Note that fragment identifiers must be unique in a template.

      If invoked upon a fragment instance then delegate to the defining template.

      Parameters:
      id - The fragment identifier
      Returns:
      the fragment or null
    • getFragmentIds

      Set<String> getFragmentIds()
      Returns an immutable set of identifiers of fragments defined in the template.

      If invoked upon a fragment instance then delegate to the defining template.

      Returns:
      the set of fragment ids
    • isFragment

      default boolean isFragment()
      Returns:
      true if this template is a fragment, false otherwise