Class BoundTemplateHandler<T>

java.lang.Object
com.blackbuild.klum.ast.runtime.internal.BoundTemplateHandler<T>
Type Parameters:
T - the type of the template being handled

public class BoundTemplateHandler<T> extends Object
A typed wrapper for scoped TemplateManager application without the need to specify the first class parameter.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <C> C
    With(Map<String,?> template, groovy.lang.Closure<C> body)
    Executes the given closure with an anonymous template.
    <C> C
    With(T template, groovy.lang.Closure<C> body)
    Executes the given closure with the given template as the template.
    <C> C
    WithAll(List<Object> newTemplates, groovy.lang.Closure<C> body)
    Executes the given closure with the given templates.
    <C> C
    WithAll(Map<Class<?>,Map<String,?>> newTemplates, groovy.lang.Closure<C> body)
    Executes the given closure with the given anonymous templates.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BoundTemplateHandler

      public BoundTemplateHandler(Class<T> type)
  • Method Details

    • With

      public <C> C With(T template, groovy.lang.Closure<C> body)
      Executes the given closure with the given template as the template. This means that all objects of the owner's type created in the scope of the closure will use the given template, which also includes objects deeper in the structure as well as objects created in a later phase. The old template is restored after the closure has been executed.
      Type Parameters:
      C - the return type of the closure
      Parameters:
      template - the template
      body - the closure to execute
      Returns:
      the result of the closure
    • With

      public <C> C With(Map<String,?> template, groovy.lang.Closure<C> body)
      Executes the given closure with an anonymous template. This means that all objects of the owner's type created in the scope of the closure will use the given template, which also includes objects deeper in the structure as well as objects created in a later phase. The template will be created from the given map (using Create.AsTemplate(Map)). The old template is restored after the closure has been executed.
      Type Parameters:
      C - the return type of the closure
      Parameters:
      template - the Map to construct the template from
      body - the closure to execute
      Returns:
      the result of the closure
    • WithAll

      public <C> C WithAll(Map<Class<?>,Map<String,?>> newTemplates, groovy.lang.Closure<C> body)
      Executes the given closure with the given anonymous templates. This is done by converting the values of the map into template objects of the type defined by the keys.
      Type Parameters:
      C - the return type of the closure
      Parameters:
      newTemplates - the templates to apply, Mapping classes to their respective anonymous templates
      body - the closure to execute
      Returns:
      the result of the closure
    • WithAll

      public <C> C WithAll(List<Object> newTemplates, groovy.lang.Closure<C> body)
      Executes the given closure with the given templates. This means that all objects of the given types created in the scope of the closure will use the given template, which also includes objects deeper in the structure. The old templates are restored after the closure has been executed.
      Parameters:
      newTemplates - the templates to apply
      body - the closure to execute
      Returns:
      the result of the closure