Skip to content

Commit

Permalink
codegen: Fix enum value generated name to not be lower cased
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 6, 2021
1 parent 12a5ddb commit 0ebb7db
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +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)));
String label = StringUtils.capitalize(name);

// Only split, capital case, and join the elements if there are non-word characters.
if (name.matches("(?U)[\\W_]")) {
for (String part : name.split("(?U)[\\W_]")) {
labelBuilder.append(StringUtils.capitalize(part.toLowerCase(Locale.US)));
}
label = labelBuilder.toString();
}
String label = labelBuilder.toString();

// If camel-casing would cause a conflict, don't camel-case this enum value.
if (constants.contains(label)) {
Expand Down

0 comments on commit 0ebb7db

Please sign in to comment.