Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codegen: Fix enum value generated name to not be lowercased #252

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,15 @@ public void run() {
for (EnumDefinition definition : enumTrait.getValues()) {
StringBuilder labelBuilder = new StringBuilder(symbol.getName());
String name = definition.getName().get();

for (String part : name.split("(?U)[\\W_]")) {
labelBuilder.append(StringUtils.capitalize(part.toLowerCase(Locale.US)));
if (part.matches(".*[a-z].*") && part.matches(".*[A-Z].*")) {
// Mixed case names should not be changed other than first letter capitalized.
labelBuilder.append(StringUtils.capitalize(part));
} else {
// For all non-mixed case parts title case first letter, followed by all other lower cased.
labelBuilder.append(StringUtils.capitalize(part.toLowerCase(Locale.US)));
}
}
String label = labelBuilder.toString();

Expand Down