@SupportedOptions(value={"translationFilesPath","skipTranslations"}) final class TranslationClassGenerator extends AbstractGenerator
The aim of this generator is to generate the classes corresponding to translation files of a MessageLogger or MessageBundle.
Modifier and Type | Class and Description |
---|---|
private class |
TranslationClassGenerator.TranslationFileFilter
Translation file Filter.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SKIP_TRANSLATIONS |
private boolean |
skipTranslations |
private static java.lang.String |
TRANSLATION_FILE_EXTENSION_PATTERN
The properties file pattern.
|
static java.lang.String |
TRANSLATION_FILES_PATH_OPTION |
private java.lang.String |
translationFilesPath |
Constructor and Description |
---|
TranslationClassGenerator(javax.annotation.processing.ProcessingEnvironment processingEnv)
Construct an instance of the Translation
Class Generator.
|
Modifier and Type | Method and Description |
---|---|
private java.util.Map<java.io.File,java.util.Map<MessageMethod,java.lang.String>> |
allInterfaceTranslations(MessageInterface messageInterface,
java.util.List<java.io.File> files) |
private java.util.List<java.io.File> |
findTranslationFiles(MessageInterface messageInterface) |
private void |
generateSourceFileFor(MessageInterface messageInterface,
java.io.File translationFile,
java.util.Map<MessageMethod,java.lang.String> translations)
Generate a class for the given translation file.
|
private static FormatValidator |
getValidatorFor(MessageMethod messageMethod,
java.lang.String translationMessage) |
void |
processTypeElement(javax.lang.model.element.TypeElement annotation,
javax.lang.model.element.TypeElement element,
MessageInterface messageInterface)
Processes a type element.
|
private java.util.Map<MessageMethod,java.lang.String> |
validateTranslationMessages(MessageInterface messageInterface,
java.io.File file)
Returns only the valid translations message corresponding
to the declared
MessageMethod methods in the
MessageBundle or MessageLogger
interface. |
elementUtils, filer, getName, getSupportedOptions, logger, processingEnv, typeUtils
public static final java.lang.String TRANSLATION_FILES_PATH_OPTION
public static final java.lang.String SKIP_TRANSLATIONS
private static final java.lang.String TRANSLATION_FILE_EXTENSION_PATTERN
private final java.lang.String translationFilesPath
private final boolean skipTranslations
public TranslationClassGenerator(javax.annotation.processing.ProcessingEnvironment processingEnv)
processingEnv
- the processing environmentpublic void processTypeElement(javax.lang.model.element.TypeElement annotation, javax.lang.model.element.TypeElement element, MessageInterface messageInterface)
AbstractGenerator
processTypeElement
in class AbstractGenerator
annotation
- the annotation who trigger the processingelement
- the element that contains the methods.messageInterface
- the message interface to implement.private java.util.Map<java.io.File,java.util.Map<MessageMethod,java.lang.String>> allInterfaceTranslations(MessageInterface messageInterface, java.util.List<java.io.File> files) throws java.io.IOException
java.io.IOException
private java.util.List<java.io.File> findTranslationFiles(MessageInterface messageInterface) throws java.io.IOException
java.io.IOException
private java.util.Map<MessageMethod,java.lang.String> validateTranslationMessages(MessageInterface messageInterface, java.io.File file)
MessageMethod
methods in the
MessageBundle
or MessageLogger
interface.messageInterface
- the message interface.file
- the translation fileprivate void generateSourceFileFor(MessageInterface messageInterface, java.io.File translationFile, java.util.Map<MessageMethod,java.lang.String> translations)
messageInterface
- the message interfacetranslationFile
- the translation filetranslations
- the translations messageprivate static FormatValidator getValidatorFor(MessageMethod messageMethod, java.lang.String translationMessage)