Class TemplatedGenerator
- java.lang.Object
-
- org.drools.model.codegen.project.template.TemplatedGenerator
-
public final class TemplatedGenerator extends java.lang.ObjectUtility 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 java.lang.StringcontextNamestatic java.lang.StringDEFAULT_TEMPLATE_BASE_PATHprotected java.lang.StringfallbackContextprotected java.lang.StringpackageNameprotected java.lang.StringsourceFilePathprotected java.lang.StringtargetTypeNameprotected static java.lang.StringTEMPLATE_FORMATprotected static java.lang.StringTEMPLATE_SUFFIXprotected java.lang.StringtemplateBasePathprotected java.lang.StringtemplateName
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TemplatedGenerator.Builderbuilder()java.util.Optional<com.github.javaparser.ast.CompilationUnit>compilationUnit()com.github.javaparser.ast.CompilationUnitcompilationUnitOrThrow()com.github.javaparser.ast.CompilationUnitcompilationUnitOrThrow(java.lang.String errorMessage)static java.lang.StringcreateTemplatePath(java.lang.String basePath, java.lang.String templateName, java.lang.String context)java.lang.StringgeneratedFilePath()java.lang.StringtargetTypeName()java.lang.StringtemplateName()java.lang.StringtemplatePath()Returns the valid template path if exists or nulljava.lang.StringuncheckedTemplatePath()Returns template path applying naming convention without verifying if exist
-
-
-
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:
-
builder
public static TemplatedGenerator.Builder builder()
-
createTemplatePath
public static java.lang.String createTemplatePath(java.lang.String basePath, java.lang.String templateName, java.lang.String context)
-
-