From 8dd547404de0c7bf3e4fd8a910b876a6d5069e52 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Sat, 15 Apr 2023 12:50:36 +0200 Subject: [PATCH] docs: add Javadoc --- .../i18n/TemplateContentGenerator.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/com/github/polpetta/mezzotre/i18n/TemplateContentGenerator.java b/src/main/java/com/github/polpetta/mezzotre/i18n/TemplateContentGenerator.java index 4e00a02..794e2ec 100644 --- a/src/main/java/com/github/polpetta/mezzotre/i18n/TemplateContentGenerator.java +++ b/src/main/java/com/github/polpetta/mezzotre/i18n/TemplateContentGenerator.java @@ -9,6 +9,14 @@ import org.apache.velocity.tools.ToolManager; import org.apache.velocity.util.StringBuilderWriter; // FIXME doc, tests + +/** + * This class aims to generate localized messages or strings either merging Velocity templates or + * taking directly the keys from {@link java.util.ResourceBundle} + * + * @author Davide Polonio + * @since 1.0 + */ public class TemplateContentGenerator { private final LocalizedMessageFactory localizedMessageFactory; @@ -18,6 +26,19 @@ public class TemplateContentGenerator { this.localizedMessageFactory = localizedMessageFactory; } + /** + * Merge a Velocity template located in the local Jar resource path with the given {@link Locale}, + * provided as a {@link String}. A {@link Consumer} is provided in order to let the user customize + * the {@link VelocityContext} with additional variables. Localization strings will be directly + * taken via the use of {@link LocalizedTool} class. + * + * @param velocityContextConsumer a lambda function that allows for the customization of {@link + * VelocityContext} instance + * @param localeAsString a {@link Locale} formatted as a {@link String}. Note that {@link + * Locale#forLanguageTag(String)} will be used for the conversion + * @param templateName the path to the local Jar resource + * @return a {@link String} containing the localized message + */ public String mergeTemplate( Consumer velocityContextConsumer, String localeAsString,