Class TemplateFormatterImpl<T extends FormatterSupport>

java.lang.Object
de.cuioss.tools.formatting.template.TemplateFormatterImpl<T>
Type Parameters:
T - at least FormatterSupport
All Implemented Interfaces:
TemplateFormatter<T>, Serializable

public final class TemplateFormatterImpl<T extends FormatterSupport> extends Object implements TemplateFormatter<T>
Formatter which is able to replace parameter inside the template based on FormatterSupport information. See de.cuioss.tools.formatting for details.
Author:
Eugen Fischer
See Also:
  • Method Details

    • format

      public String format(T reference)
      replace attributes from template by attribute values from the map. missing template attributes will be ignored and doesn't add to result at all.
      Specified by:
      format in interface TemplateFormatter<T extends FormatterSupport>
      Parameters:
      reference - must not be null
      Returns:
      completed template
    • createFormatter

      public static <F extends FormatterSupport> TemplateFormatter<F> createFormatter(String template, Class<F> sourceType)
      The created TemplateFormatter provide only usage of simple expression language with squared brackets.
      Parameters:
      template - must not be null
      sourceType - must not be null
      Returns:
      TemplateFormatter which using template and lexer which was forwarded
    • createFormatter

      public static <F extends FormatterSupport> TemplateFormatter<F> createFormatter(String template, F source)
      Parameters:
      template - must not be null
      source - must not be null
      Returns:
      TemplateFormatter
    • createFormatter

      public static <F extends FormatterSupport> TemplateFormatter<F> createFormatter(String template, Lexer<F> lexer)
      Parameters:
      template - must not be null
      lexer - must not be null
      Returns:
      TemplateFormatter which using template and lexer which was forwarded
    • createFormatter

      public static <F extends FormatterSupport> TemplateFormatter<F> createFormatter(String template, Class<F> sourceType, boolean strict)
      The created TemplateFormatter provide only usage of simple expression language with squared brackets.
      Parameters:
      template - must not be null
      sourceType - must not be null
      strict - use strict mode for pattern matching (only match exact name) instead of best fitting
      Returns:
      TemplateFormatter which using template and lexer which was forwarded
    • createFormatter

      public static <F extends FormatterSupport> TemplateFormatter<F> createFormatter(String template, F source, boolean strict)
      Parameters:
      template - must not be null
      source - must not be null
      strict - use strict mode for pattern matching (only match exact name) instead of best fitting
      Returns:
      TemplateFormatter
    • createFormatter

      public static <F extends FormatterSupport> TemplateFormatter<F> createFormatter(String template, Lexer<F> lexer, boolean strict)
      Parameters:
      template - must not be null
      lexer - must not be null
      strict - use strict mode for pattern matching (only match exact name) instead of best fitting
      Returns:
      TemplateFormatter which using template and lexer which was forwarded
    • builder

      Returns:
      a newly created TemplateFormatterImpl.TemplateBuilder