Class TemplatedGenerator
- java.lang.Object
-
- org.drools.model.project.codegen.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTemplatedGenerator.Builder
-
Field Summary
Fields Modifier and Type Field Description protected DroolsModelBuildContextcontextstatic StringDEFAULT_TEMPLATE_BASE_PATHprotected StringfallbackContextprotected StringpackageNameprotected StringsourceFilePathprotected StringtargetTypeNameprotected static StringTEMPLATE_FORMATprotected static StringTEMPLATE_SUFFIXprotected StringtemplateBasePathprotected StringtemplateName
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TemplatedGenerator.Builderbuilder()Optional<com.github.javaparser.ast.CompilationUnit>compilationUnit()com.github.javaparser.ast.CompilationUnitcompilationUnitOrThrow()com.github.javaparser.ast.CompilationUnitcompilationUnitOrThrow(String errorMessage)static StringcreateTemplatePath(String basePath, String templateName, String context)StringgeneratedFilePath()StringtargetTypeName()StringtemplateName()StringtemplatePath()Returns the valid template path if exists or nullStringuncheckedTemplatePath()Returns template path applying naming convention without verifying if exist
-
-
-
Field Detail
-
DEFAULT_TEMPLATE_BASE_PATH
public static final String DEFAULT_TEMPLATE_BASE_PATH
- See Also:
- Constant Field Values
-
TEMPLATE_FORMAT
protected static final String TEMPLATE_FORMAT
- See Also:
- Constant Field Values
-
TEMPLATE_SUFFIX
protected static final String TEMPLATE_SUFFIX
- See Also:
- Constant Field Values
-
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
-
context
protected final DroolsModelBuildContext context
-
-
Method Detail
-
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()
-
-