Module de.cuioss.java.tools
Class TemplateFormatterImpl<T extends FormatterSupport>
java.lang.Object
de.cuioss.tools.formatting.template.TemplateFormatterImpl<T>
- Type Parameters:
T- at leastFormatterSupport
- 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classTemplate Builder -
Method Summary
Modifier and TypeMethodDescriptionbuilder()static <F extends FormatterSupport>
TemplateFormatter<F>createFormatter(String template, Lexer<F> lexer) static <F extends FormatterSupport>
TemplateFormatter<F>createFormatter(String template, Lexer<F> lexer, boolean strict) static <F extends FormatterSupport>
TemplateFormatter<F>createFormatter(String template, F source) static <F extends FormatterSupport>
TemplateFormatter<F>createFormatter(String template, F source, boolean strict) 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.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.replace attributes from template by attribute values from the map.
-
Method Details
-
format
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:
formatin interfaceTemplateFormatter<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 nullsourceType- 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 nullsource- 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 nulllexer- 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 nullsourceType- must not be nullstrict- 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 nullsource- must not be nullstrict- 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 nulllexer- must not be nullstrict- 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
-