Class TemplatedGenerator


  • public final class TemplatedGenerator
    extends java.lang.Object
    Utility class to handle multi platform template generation. Template naming convention is the following: templateName + context.name() + "Template.java" e.g.: ApplicationConfigQuarkusTemplate.java PredictionModelsSpringTemplate.java ApplicationJavaTemplate.java By default targetTypeName value is ''templateName'' By default templateBasePath value is ''/class-templates/'' It is possible to specify a fallback context with fallbackContext
    • Field Detail

      • DEFAULT_TEMPLATE_BASE_PATH

        public static final java.lang.String DEFAULT_TEMPLATE_BASE_PATH
        See Also:
        Constant Field Values
      • TEMPLATE_FORMAT

        protected static final java.lang.String TEMPLATE_FORMAT
        See Also:
        Constant Field Values
      • TEMPLATE_SUFFIX

        protected static final java.lang.String TEMPLATE_SUFFIX
        See Also:
        Constant Field Values
      • packageName

        protected final java.lang.String packageName
      • sourceFilePath

        protected final java.lang.String sourceFilePath
      • templateBasePath

        protected final java.lang.String templateBasePath
      • templateName

        protected final java.lang.String templateName
      • targetTypeName

        protected final java.lang.String targetTypeName
      • fallbackContext

        protected final java.lang.String fallbackContext
      • contextName

        protected final java.lang.String contextName
    • Method Detail

      • generatedFilePath

        public java.lang.String generatedFilePath()
      • templateName

        public java.lang.String templateName()
      • targetTypeName

        public java.lang.String targetTypeName()
      • compilationUnit

        public java.util.Optional<com.github.javaparser.ast.CompilationUnit> compilationUnit()
      • compilationUnitOrThrow

        public com.github.javaparser.ast.CompilationUnit compilationUnitOrThrow​(java.lang.String errorMessage)
      • compilationUnitOrThrow

        public com.github.javaparser.ast.CompilationUnit compilationUnitOrThrow()
      • templatePath

        public java.lang.String templatePath()
        Returns the valid template path if exists or null
        Returns:
      • uncheckedTemplatePath

        public java.lang.String uncheckedTemplatePath()
        Returns template path applying naming convention without verifying if exist
        Returns:
      • createTemplatePath

        public static java.lang.String createTemplatePath​(java.lang.String basePath,
                                                          java.lang.String templateName,
                                                          java.lang.String context)