Class TemplatedGenerator

java.lang.Object
org.drools.model.codegen.project.template.TemplatedGenerator

public final class TemplatedGenerator extends 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 Details

    • DEFAULT_TEMPLATE_BASE_PATH

      public static final String DEFAULT_TEMPLATE_BASE_PATH
      See Also:
    • TEMPLATE_FORMAT

      protected static final String TEMPLATE_FORMAT
      See Also:
    • TEMPLATE_SUFFIX

      protected static final String TEMPLATE_SUFFIX
      See Also:
    • packageName

      protected final String packageName
    • sourceFilePath

      protected final String sourceFilePath
    • templateBasePath

      protected final String templateBasePath
    • templateName

      protected final String templateName
    • targetTypeName

      protected final String targetTypeName
    • fallbackContext

      protected final String fallbackContext
    • contextName

      protected final String contextName
  • Method Details

    • generatedFilePath

      public String generatedFilePath()
    • templateName

      public String templateName()
    • targetTypeName

      public String targetTypeName()
    • compilationUnit

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

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

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

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

      public String uncheckedTemplatePath()
      Returns template path applying naming convention without verifying if exist
      Returns:
    • builder

      public static TemplatedGenerator.Builder builder()
    • createTemplatePath

      public static String createTemplatePath(String basePath, String templateName, String context)