de.cuioss.tools.formatting.package-info Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cui-java-tools Show documentation
Show all versions of cui-java-tools Show documentation
Utility Library acting as a replacement for googles guava,
certain apache-commons libraries and logging
facades/frameworks.
/**
* Configurable formatting for complex structures
* The Problem
*
* Provide a text representation for given complex object. As a plus the
* formatting should be easily configurable with a simple DSL-style template
* language.
*
The Solution
*
* The {@link de.cuioss.tools.formatting} framework presented here.
*
*
* The starting point is
* {@link de.cuioss.tools.formatting.template.FormatterSupport} providing two
* methods:
*
* - {@link de.cuioss.tools.formatting.template.FormatterSupport#getSupportedPropertyNames()}:
* Provides the property names that can be used for formatting
* - {@link de.cuioss.tools.formatting.template.FormatterSupport#getAvailablePropertyValues()}:
* Provides a name with with the supported names and values.
*
*
* The other interface needed is
* {@link de.cuioss.tools.formatting.template.TemplateFormatter} defining the
* method
* {@link de.cuioss.tools.formatting.template.TemplateFormatter#format(de.cuioss.tools.formatting.template.FormatterSupport)}
* doing the actual formatting.
*
* Sample
Dto PersonName implementing
* {@link de.cuioss.tools.formatting.template.FormatterSupport}
*
*
*
final PersonName personName = PersonName.builder()
.setFamilyName("Fischers")
.setGivenName("Fritz")
.setMiddleName("Felix")
.setGivenNameSuffix("Dr.")
.build();
final TemplateFormatter<PersonName> formatter = TemplateFormatterImpl.builder()
.useTemplate("[familyName], [givenName], [middleName] [givenNameSuffix]")
.forType(PersonName.class);
assertEquals("Fischers, Fritz, Felix Dr.", formatter.format(personName));
*
*
*
*
*/
package de.cuioss.tools.formatting;