Skip to content

Commit dfe5c06

Browse files
committed
Updating descriptive name to use capital casing
1 parent 55e9713 commit dfe5c06

File tree

12 files changed

+46
-66
lines changed

12 files changed

+46
-66
lines changed

codegen/src/main/java/software/amazon/awssdk/codegen/naming/DefaultNamingStrategy.java

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import static software.amazon.awssdk.codegen.internal.Constant.REQUEST_CLASS_SUFFIX;
2424
import static software.amazon.awssdk.codegen.internal.Constant.RESPONSE_CLASS_SUFFIX;
2525
import static software.amazon.awssdk.codegen.internal.Utils.unCapitalize;
26+
import static software.amazon.awssdk.utils.NamingUtils.pascalCase;
27+
import static software.amazon.awssdk.utils.NamingUtils.splitOnWordBoundaries;
2628

2729
import java.util.Arrays;
2830
import java.util.Collections;
@@ -183,10 +185,6 @@ private String screamCase(String word) {
183185
return Stream.of(splitOnWordBoundaries(word)).map(s -> s.toUpperCase(Locale.US)).collect(joining("_"));
184186
}
185187

186-
private String pascalCase(String word) {
187-
return Stream.of(splitOnWordBoundaries(word)).map(StringUtils::lowerCase).map(Utils::capitalize).collect(joining());
188-
}
189-
190188
private String getCustomizedPackageName(String serviceName, String defaultPattern) {
191189
return String.format(defaultPattern, StringUtils.lowerCase(serviceName));
192190
}
@@ -357,31 +355,4 @@ private boolean isDisallowedNameForShape(String name, Shape parentShape) {
357355
return RESERVED_STRUCTURE_METHOD_NAMES.contains(name);
358356
}
359357
}
360-
361-
private String[] splitOnWordBoundaries(String toSplit) {
362-
String result = toSplit;
363-
364-
// All non-alphanumeric characters are spaces
365-
result = result.replaceAll("[^A-Za-z0-9]+", " "); // acm-success -> "acm success"
366-
367-
// If a number has a standalone v in front of it, separate it out (version).
368-
result = result.replaceAll("([^a-z]{2,})v([0-9]+)", "$1 v$2 ") // TESTv4 -> "TEST v4 "
369-
.replaceAll("([^A-Z]{2,})V([0-9]+)", "$1 V$2 "); // TestV4 -> "Test V4 "
370-
371-
// Add a space between camelCased words
372-
result = String.join(" ", result.split("(?<=[a-z])(?=[A-Z]([a-zA-Z]|[0-9]))")); // AcmSuccess -> "Acm Success"
373-
374-
// Add a space after acronyms
375-
result = result.replaceAll("([A-Z]+)([A-Z][a-z])", "$1 $2"); // ACMSuccess -> "ACM Success"
376-
377-
// Add space after a number in the middle of a word
378-
result = result.replaceAll("([0-9])([a-zA-Z])", "$1 $2"); // s3ec2 -> "s3 ec2"
379-
380-
// Remove extra spaces - multiple consecutive ones or those and the beginning/end of words
381-
result = result.replaceAll(" +", " ") // "Foo Bar" -> "Foo Bar"
382-
.trim(); // " Foo " -> Foo
383-
384-
return result.split(" ");
385-
}
386-
387358
}

codegen/src/main/java/software/amazon/awssdk/codegen/poet/model/ResponseMetadataSpec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import software.amazon.awssdk.codegen.poet.ClassSpec;
3131
import software.amazon.awssdk.codegen.poet.PoetExtensions;
3232
import software.amazon.awssdk.codegen.poet.PoetUtils;
33-
import software.amazon.awssdk.codegen.utils.NamingUtils;
3433
import software.amazon.awssdk.utils.CollectionUtils;
34+
import software.amazon.awssdk.utils.NamingUtils;
3535
import software.amazon.awssdk.utils.StringUtils;
3636

3737
/**

release-scripts/src/main/java/software/amazon/awssdk/release/NewServiceMain.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@
2424
import java.nio.file.Paths;
2525
import java.nio.file.SimpleFileVisitor;
2626
import java.nio.file.attribute.BasicFileAttributes;
27+
import java.util.stream.Collectors;
28+
import java.util.stream.Stream;
2729
import org.apache.commons.cli.CommandLine;
2830
import org.apache.commons.io.FileUtils;
2931
import org.apache.commons.lang3.StringUtils;
3032
import org.w3c.dom.Document;
3133
import org.w3c.dom.Node;
34+
import software.amazon.awssdk.utils.NamingUtils;
3235
import software.amazon.awssdk.utils.Validate;
3336

3437
/**
@@ -134,14 +137,20 @@ private String replacePlaceholders(String line) {
134137
"{{PROTOCOL}}"
135138
};
136139
String[] replaceList = {
137-
serviceModuleName,
138-
serviceId,
139-
mavenProjectVersion,
140-
serviceProtocol
140+
serviceModuleName,
141+
mavenName(serviceId),
142+
mavenProjectVersion,
143+
serviceProtocol
141144
};
142145
return StringUtils.replaceEach(line, searchList, replaceList);
143146
}
144147

148+
private String mavenName(String serviceId) {
149+
return Stream.of(NamingUtils.splitOnWordBoundaries(serviceId))
150+
.map(StringUtils::capitalize)
151+
.collect(Collectors.joining(" "));
152+
}
153+
145154
private class AddSubmoduleTransformer extends PomTransformer {
146155
@Override
147156
protected void updateDocument(Document doc) {

services/codestarnotifications/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
<version>2.10.72-SNAPSHOT</version>
2525
</parent>
2626
<artifactId>codestarnotifications</artifactId>
27-
<name>AWS Java SDK :: Services :: codestar notifications</name>
28-
<description>The AWS Java SDK for codestar notifications module holds the client classes that are used for
29-
communicating with codestar notifications.
27+
<name>AWS Java SDK :: Services :: Codestar Notifications</name>
28+
<description>The AWS Java SDK for Codestar Notifications module holds the client classes that are used for
29+
communicating with Codestar Notifications.
3030
</description>
3131
<url>https://aws.amazon.com/sdkforjava</url>
3232
<build>

services/forecast/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
<version>2.10.72-SNAPSHOT</version>
2525
</parent>
2626
<artifactId>forecast</artifactId>
27-
<name>AWS Java SDK :: Services :: forecast</name>
28-
<description>The AWS Java SDK for forecast module holds the client classes that are used for
29-
communicating with forecast.
27+
<name>AWS Java SDK :: Services :: Forecast</name>
28+
<description>The AWS Java SDK for Forecast module holds the client classes that are used for
29+
communicating with Forecast.
3030
</description>
3131
<url>https://aws.amazon.com/sdkforjava</url>
3232
<build>

services/forecastquery/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
<version>2.10.72-SNAPSHOT</version>
2525
</parent>
2626
<artifactId>forecastquery</artifactId>
27-
<name>AWS Java SDK :: Services :: forecastquery</name>
28-
<description>The AWS Java SDK for forecastquery module holds the client classes that are used for
29-
communicating with forecastquery.
27+
<name>AWS Java SDK :: Services :: Forecastquery</name>
28+
<description>The AWS Java SDK for Forecastquery module holds the client classes that are used for
29+
communicating with Forecastquery.
3030
</description>
3131
<url>https://aws.amazon.com/sdkforjava</url>
3232
<build>

services/imagebuilder/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
<version>2.10.72-SNAPSHOT</version>
2525
</parent>
2626
<artifactId>imagebuilder</artifactId>
27-
<name>AWS Java SDK :: Services :: imagebuilder</name>
28-
<description>The AWS Java SDK for imagebuilder module holds the client classes that are used for
29-
communicating with imagebuilder.
27+
<name>AWS Java SDK :: Services :: Imagebuilder</name>
28+
<description>The AWS Java SDK for Imagebuilder module holds the client classes that are used for
29+
communicating with Imagebuilder.
3030
</description>
3131
<url>https://aws.amazon.com/sdkforjava</url>
3232
<build>

services/kendra/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
<version>2.10.72-SNAPSHOT</version>
2525
</parent>
2626
<artifactId>kendra</artifactId>
27-
<name>AWS Java SDK :: Services :: kendra</name>
28-
<description>The AWS Java SDK for kendra module holds the client classes that are used for
29-
communicating with kendra.
27+
<name>AWS Java SDK :: Services :: Kendra</name>
28+
<description>The AWS Java SDK for Kendra module holds the client classes that are used for
29+
communicating with Kendra.
3030
</description>
3131
<url>https://aws.amazon.com/sdkforjava</url>
3232
<build>

services/savingsplans/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
<version>2.10.72-SNAPSHOT</version>
2525
</parent>
2626
<artifactId>savingsplans</artifactId>
27-
<name>AWS Java SDK :: Services :: savingsplans</name>
28-
<description>The AWS Java SDK for savingsplans module holds the client classes that are used for
29-
communicating with savingsplans.
27+
<name>AWS Java SDK :: Services :: Savingsplans</name>
28+
<description>The AWS Java SDK for Savingsplans module holds the client classes that are used for
29+
communicating with Savingsplans.
3030
</description>
3131
<url>https://aws.amazon.com/sdkforjava</url>
3232
<build>

services/schemas/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
<version>2.10.72-SNAPSHOT</version>
2525
</parent>
2626
<artifactId>schemas</artifactId>
27-
<name>AWS Java SDK :: Services :: schemas</name>
28-
<description>The AWS Java SDK for schemas module holds the client classes that are used for
29-
communicating with schemas.
27+
<name>AWS Java SDK :: Services :: Schemas</name>
28+
<description>The AWS Java SDK for Schemas module holds the client classes that are used for
29+
communicating with Schemas.
3030
</description>
3131
<url>https://aws.amazon.com/sdkforjava</url>
3232
<build>

services/signer/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
<version>2.10.72-SNAPSHOT</version>
2525
</parent>
2626
<artifactId>signer</artifactId>
27-
<name>AWS Java SDK :: Services :: signer</name>
28-
<description>The AWS Java SDK for signer module holds the client classes that are used for
29-
communicating with signer.
27+
<name>AWS Java SDK :: Services :: Signer</name>
28+
<description>The AWS Java SDK for Signer module holds the client classes that are used for
29+
communicating with Signer.
3030
</description>
3131
<url>https://aws.amazon.com/sdkforjava</url>
3232
<build>

codegen/src/main/java/software/amazon/awssdk/codegen/utils/NamingUtils.java renamed to utils/src/main/java/software/amazon/awssdk/utils/NamingUtils.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
* permissions and limitations under the License.
1414
*/
1515

16-
package software.amazon.awssdk.codegen.utils;
16+
package software.amazon.awssdk.utils;
1717

1818
import static java.util.stream.Collectors.joining;
1919

2020
import java.util.stream.Stream;
21-
import software.amazon.awssdk.codegen.internal.Utils;
22-
import software.amazon.awssdk.utils.StringUtils;
21+
import software.amazon.awssdk.annotations.SdkProtectedApi;
2322

23+
@SdkProtectedApi
2424
public final class NamingUtils {
2525

2626
private NamingUtils() {
@@ -37,7 +37,7 @@ public static String[] splitOnWordBoundaries(String toSplit) {
3737
.replaceAll("([^A-Z]{2,})V([0-9]+)", "$1 V$2 "); // TestV4 -> "Test V4 "
3838

3939
// Add a space between camelCased words
40-
result = String.join(" ", result.split("(?<=[a-z])(?=[A-Z]([a-zA-Z]|[0-9]))")); // AcmSuccess -> "Acm Success"
40+
result = String.join(" ", result.split("(?<=[a-z])(?=[A-Z]([a-zA-Z]|[0-9]))")); // AcmSuccess -> // "Acm Success"
4141

4242
// Add a space after acronyms
4343
result = result.replaceAll("([A-Z]+)([A-Z][a-z])", "$1 $2"); // ACMSuccess -> "ACM Success"
@@ -53,10 +53,10 @@ public static String[] splitOnWordBoundaries(String toSplit) {
5353
}
5454

5555
public static String pascalCase(String word) {
56-
return Stream.of(splitOnWordBoundaries(word)).map(StringUtils::lowerCase).map(Utils::capitalize).collect(joining());
56+
return Stream.of(splitOnWordBoundaries(word)).map(StringUtils::lowerCase).map(StringUtils::capitalize).collect(joining());
5757
}
5858

5959
public static String pascalCase(String... words) {
60-
return Stream.of(words).map(StringUtils::lowerCase).map(Utils::capitalize).collect(joining());
60+
return Stream.of(words).map(StringUtils::lowerCase).map(StringUtils::capitalize).collect(joining());
6161
}
6262
}

0 commit comments

Comments
 (0)