Class CtxApiRenderer

java.lang.Object
dk.mada.jaxrs.generator.mpclient.api.tmpl.CtxApiRenderer

public class CtxApiRenderer extends Object
Generated Renderer.
  • Constructor Details

    • CtxApiRenderer

      public CtxApiRenderer(Function<Object,String> formatter, Function<String,String> escaper)
      Renderer constructor for manual wiring.
      Parameters:
      formatter - formatter if null the static formatter will be used.
      escaper - escaper if null the static escaper will be used
    • CtxApiRenderer

      public CtxApiRenderer()
      Renderer constructor for reflection (use of() instead). For programmatic consider using of() for a shared singleton.
  • Method Details

    • execute

      public void execute(CtxApi model, Appendable a) throws IOException
      Renders the passed in model.
      Parameters:
      model - a model assumed never to be null.
      a - the appendable to write to.
      Throws:
      IOException - if there is an error writing to the appendable
    • execute

      public String execute(CtxApi model)
      Convenience method that directly renders the model as a String.
      Parameters:
      model - never null.
      Returns:
      the rendered model.
    • execute

      protected void execute(CtxApi model, Appendable a, Function<Object,String> formatter, Function<String,String> escaper) throws IOException
      Renders the passed in model.
      Parameters:
      model - a model assumed never to be null.
      a - appendable to write to.
      formatter - formats variables before they are passed to the escaper
      escaper - used to write escaped variables
      Throws:
      IOException - if an error occurs while writing to the appendable
    • supportsType

      public boolean supportsType(Class<?> type)
      If this template support the model class
      Parameters:
      type - model class.
      Returns:
      true if the renderer supports the class
    • templatePath

      public String templatePath()
      Template path.
      Returns:
      template path of resource or pseudo inline path
    • templateName

      public String templateName()
      Logical template name.
      Returns:
      template name
    • templateCharset

      public Charset templateCharset()
      Template charset name.
      Returns:
      charset name of template
    • templateString

      public String templateString()
      Template contents or blank if path.
      Returns:
      inline template
    • templateEscaper

      public Function<String,String> templateEscaper()
      Current escaper.
      Returns:
      escaper
    • templateFormatter

      public Function<Object,String> templateFormatter()
      Current formatter.
      Returns:
      formatter
    • modelClass

      public Class<?> modelClass()
      Model class.
      Returns:
      class used as model (annotated with JStache).
    • of

      public static CtxApiRenderer of()
      Convience static factory that will reuse the same singleton instance.
      Returns:
      renderer same as calling no-arg constructor but is cached with singleton instance
    • render

      public static void render(CtxApi data, Appendable unescapedWriter, Function<Object,String> formatter, Function<String,String> escaper) throws IOException
      Renders the passed in model.
      Parameters:
      data - model
      unescapedWriter - appendable to write to.
      formatter - formats variables before they are passed to the escaper.
      escaper - used to write escaped variables.
      Throws:
      IOException - if an error occurs while writing to the appendable