Skip to content

Commit

Permalink
[bug][kotlin] sanitize model names according to convention (#16267)
Browse files Browse the repository at this point in the history
* [bug][kotlin] sanitize model names according to convention

* [bug][kotlin] revert to english word sanitization except minus

---------

Co-authored-by: Theo Meneau <[email protected]>
  • Loading branch information
wing328 and tmeneau authored Aug 7, 2023
1 parent f6ac603 commit 097385b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ public String toModelName(final String name) {
return importMapping.get(name);
}

String modifiedName = name.replaceAll("\\.", "");
String modifiedName = name.replaceAll("\\.", "").replaceAll("-", "_");

String nameWithPrefixSuffix = sanitizeKotlinSpecificNames(modifiedName);
if (!StringUtils.isEmpty(modelNamePrefix)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void convertModelName() {
assertEquals(codegen.toModelName("Pony?"), "PonyQuestionMark");
assertEquals(codegen.toModelName("$name"), "DollarName");
assertEquals(codegen.toModelName("nam#e"), "NamHashE");
assertEquals(codegen.toModelName("$another-fake?"), "DollarAnotherMinusFakeQuestionMark");
assertEquals(codegen.toModelName("$another-fake?"), "DollarAnotherFakeQuestionMark");
assertEquals(codegen.toModelName("Pony>=>="), "PonyGreaterThanEqualGreaterThanEqual");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ public static Object[][] modelNames() {
{"$", new ModelNameTest("$", "Dollar")},
{"for", new ModelNameTest("`for`", "For")},
{"One<Two", new ModelNameTest("One<Two", "OneLessThanTwo")},
{"One-Two", new ModelNameTest("One-Two", "OneTwo")},
{"this is a test", new ModelNameTest("this is a test", "ThisIsATest")}
};
}
Expand Down

0 comments on commit 097385b

Please sign in to comment.