Package io.cui.tools.formatting.template
Class TemplateFormatterImpl<T extends FormatterSupport>
- java.lang.Object
-
- io.cui.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 onFormatterSupportinformation. Seeio.cui.tools.formattingfor details.- Author:
- Eugen Fischer
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTemplateFormatterImpl.TemplateBuilderTemplate Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TemplateFormatterImpl.TemplateBuilderbuilder()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, 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, 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.booleanequals(Object o)Stringformat(T reference)replace attributes from template by attribute values from the map.inthashCode()StringtoString()
-
-
-
Method Detail
-
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:
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
public static TemplateFormatterImpl.TemplateBuilder builder()
- Returns:
- a newly created
TemplateFormatterImpl.TemplateBuilder
-
-