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 Detail

      • 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
      • getVariant

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

        List<ParameterDeclaration> getParameterDeclarations()
        If invoked upon a fragment instance then delegate to the defining template.
        Returns:
        an immutable list of all 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