[All generators] Supports of hyphen-case to camelCase (#6399)

* Supports of hyphen-case to camelCase

* Add unit tests for the new section in the camelize function.
This commit is contained in:
Jean-François Côté
2017-09-07 01:14:22 -04:00
committed by wing328
parent 29a3a4b336
commit 0cf82d7ae3
2 changed files with 11 additions and 1 deletions

View File

@@ -3251,7 +3251,7 @@ public class DefaultCodegen {
word = m.replaceAll(rep);
}
// Remove all underscores
// Remove all underscores (underscore_case to camelCase)
p = Pattern.compile("(_)(.)");
m = p.matcher(word);
while (m.find()) {
@@ -3259,6 +3259,14 @@ public class DefaultCodegen {
m = p.matcher(word);
}
// Remove all hyphens (hyphen-case to camelCase)
p = Pattern.compile("(-)(.)");
m = p.matcher(word);
while (m.find()) {
word = m.replaceFirst(m.group(2).toUpperCase());
m = p.matcher(word);
}
if (lowercaseFirstLetter && word.length() > 0) {
word = word.substring(0, 1).toLowerCase() + word.substring(1);
}