in codegen/src/main/java/software/amazon/awssdk/codegen/customization/processors/ShapeSubstitutionsProcessor.java [155:212]
private void preprocessSubstituteShapeReferencesInShape(
String shapeName, Shape shape, ServiceModel serviceModel) {
// structure members
if (shape.getMembers() != null) {
for (Entry<String, Member> entry : shape.getMembers().entrySet()) {
String memberName = entry.getKey();
Member member = entry.getValue();
String memberShapeName = member.getShape();
Shape memberShape = serviceModel.getShapes().get(memberShapeName);
// First check if it's a list-type member and that the shape of
// its list element should be substituted
if (Utils.isListShape(memberShape)) {
Member nestedListMember = memberShape.getListMember();
String nestedListMemberOriginalShape = nestedListMember.getShape();
ShapeSubstitution appliedSubstitutionOnListMember = substituteMemberShape(nestedListMember);
if (appliedSubstitutionOnListMember != null &&
appliedSubstitutionOnListMember.getEmitFromMember() != null) {
// we will handle the emitFromMember customizations in post-process stage
trackListMemberSubstitution(shapeName, memberName, nestedListMemberOriginalShape);
}
} else {
// Then check if the shape of the member itself is to be substituted
ShapeSubstitution appliedSubstitution = substituteMemberShape(member);
if (appliedSubstitution != null &&
appliedSubstitution.getEmitFromMember() != null) {
// we will handle the emitFromMember customizations in post-process stage
trackShapeMemberSubstitution(shapeName, memberName, memberShapeName);
}
}
}
} else if (shape.getMapKeyType() != null) {
// no need to check if the shape is a list, since a list shape is
// always referenced by a top-level structure shape and that's already
// handled by the code above
// map key is not allowed to be substituted
String mapKeyShape = shape.getMapKeyType().getShape();
if (shapeSubstitutions.containsKey(mapKeyShape)) {
throw new IllegalStateException(
"shapeSubstitution customization found for shape "
+ mapKeyShape + ", but this shape is the key for a map shape.");
}
} else if (shape.getMapValueType() != null) {
// map value is not allowed to be substituted
String mapValShape = shape.getMapValueType().getShape();
if (shapeSubstitutions.containsKey(mapValShape)) {
throw new IllegalStateException(
"shapeSubstitution customization found for shape "
+ mapValShape + ", but this shape is the value for a map shape.");
}
}
}