in codegen/src/main/java/software/amazon/awssdk/codegen/customization/processors/RenameShapesProcessor.java [43:94]
public void preprocess(ServiceModel serviceModel) {
if (renameShapes == null || renameShapes.isEmpty()) {
return;
}
// sanity check
for (Entry<String, String> entry : renameShapes.entrySet()) {
String originalName = entry.getKey();
String newName = entry.getValue();
Shape originalShape = serviceModel.getShapes().get(originalName);
if (originalShape == null) {
throw new IllegalStateException(
String.format("Cannot find shape [%s] in the model when processing "
+ "customization config renameShapes.%s", originalName, originalName));
}
if (serviceModel.getShapes().containsKey(newName)) {
throw new IllegalStateException(
String.format("The shape [%s] for the new name is already in the model when processing "
+ "customization config renameShapes.%s", newName, originalName));
}
}
for (Entry<String, Shape> entry : serviceModel.getShapes().entrySet()) {
String shapeName = entry.getKey();
Shape shape = entry.getValue();
preprocessRenameMemberShapes(shape);
}
for (Operation operation : serviceModel.getOperations().values()) {
if (operation.getInput() != null) {
preprocessRenameInputShape(operation.getInput());
}
if (operation.getOutput() != null) {
preprocessRenameOutputShape(operation.getOutput());
}
if (operation.getErrors() != null) {
for (ErrorMap error : operation.getErrors()) {
preprocessRenameErrorShape(error);
}
}
}
for (Entry<String, String> entry : renameShapes.entrySet()) {
String originalName = entry.getKey();
String newName = entry.getValue();
Shape shape = serviceModel.getShapes().remove(originalName);
serviceModel.getShapes().put(newName, shape);
}
}