Skip to content

Commit

Permalink
codegen: Fix enum value generated name to not be lower cased (#252)
Browse files Browse the repository at this point in the history
Fixes the generated enum value names to not be lower cased when
capitalized.

Related to aws/aws-sdk-go-v2#1013
  • Loading branch information
jasdel committed Jan 7, 2021
1 parent 12a5ddb commit 0ceb367
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit 0ceb367

Please sign in to comment.