Skip to content

Commit

Permalink
added local variable prefix in codegen configurator.
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoMario committed Feb 10, 2024
1 parent 986e90a commit 478335b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(name = "modelNameSuffix", required = false)
private String modelNameSuffix;

/**
* Adds a prefix for all generated local variables
*/
@Parameter(name = "localVariablePrefix", required = false)
private String localVariablePrefix;

/**
* Sets an optional ignoreFileOverride path
*/
Expand Down Expand Up @@ -409,6 +415,10 @@ protected void execute_() throws MojoExecutionException {
configurator.setModelNameSuffix(modelNameSuffix);
}

if (isNotEmpty(localVariablePrefix)) {
configurator.setLocalVariablePrefix(localVariablePrefix);
}

if (null != templateDirectory) {
configurator.setTemplateDir(templateDirectory.getAbsolutePath());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class CodegenConfigurator implements Serializable {
private String invokerPackage;
private String modelNamePrefix;
private String modelNameSuffix;
private String localVariablePrefix;
private String groupId;
private String artifactId;
private String artifactVersion;
Expand Down Expand Up @@ -142,6 +143,15 @@ public CodegenConfigurator setModelNameSuffix(String suffix) {
return this;
}

public String getLocalVariablePrefix() {
return localVariablePrefix;
}

public CodegenConfigurator setLocalVariablePrefix(String localVariablePrefix) {
this.localVariablePrefix = localVariablePrefix;
return this;
}

public boolean isVerbose() {
return verbose;
}
Expand Down Expand Up @@ -427,6 +437,7 @@ public ClientOptInput toClientOptInput() {
checkAndSetAdditionalProperty(templateDir, toAbsolutePathStr(templateDir), CodegenConstants.TEMPLATE_DIR);
checkAndSetAdditionalProperty(modelNamePrefix, CodegenConstants.MODEL_NAME_PREFIX);
checkAndSetAdditionalProperty(modelNameSuffix, CodegenConstants.MODEL_NAME_SUFFIX);
checkAndSetAdditionalProperty(localVariablePrefix, CodegenConstants.LOCAL_VARIABLE_PREFIX);
checkAndSetAdditionalProperty(gitUserId, CodegenConstants.GIT_USER_ID);
checkAndSetAdditionalProperty(gitRepoId, CodegenConstants.GIT_REPO_ID);
checkAndSetAdditionalProperty(releaseNote, CodegenConstants.RELEASE_NOTE);
Expand Down

0 comments on commit 478335b

Please sign in to comment.