Skip to content

Commit 5112fdd

Browse files
Simplify type replacement validation logic
Co-authored-by: Jordon Phillips <JordonPhillips@users.noreply.github.com>
1 parent fe83c5e commit 5112fdd

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

smithy-model/src/main/java/software/amazon/smithy/model/transform/ReplaceShapes.java

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import software.amazon.smithy.model.shapes.Shape;
3636
import software.amazon.smithy.model.shapes.ShapeId;
3737
import software.amazon.smithy.model.shapes.ShapeVisitor;
38+
import software.amazon.smithy.model.shapes.SimpleShape;
3839
import software.amazon.smithy.model.shapes.StructureShape;
3940
import software.amazon.smithy.model.shapes.UnionShape;
4041
import software.amazon.smithy.utils.OptionalUtils;
@@ -135,26 +136,12 @@ private void assertShapeTypeChangesSound(Model model, List<Shape> shouldReplace)
135136
});
136137
}
137138

138-
private boolean isReplaceable(Shape shape) {
139-
return !shape.isDocumentShape()
140-
&& !shape.isMapShape()
141-
&& !shape.isMemberShape()
142-
&& !shape.isOperationShape()
143-
&& !shape.isResourceShape()
144-
&& !shape.isServiceShape()
145-
&& !shape.isStructureShape()
146-
&& !shape.isUnionShape();
147-
}
148-
149139
private boolean isReplacementValid(Model model, Shape left, Shape right) {
150-
if (isListCollection(left) && isListCollection(right)) {
140+
if (left instanceof CollectionShape && right instanceof CollectionShape) {
151141
validateListCollectionReplacement(model, (CollectionShape) left, (CollectionShape) right);
142+
return true;
152143
}
153-
return isReplaceable(left) && isReplaceable(right) && isListCollection(left) == isListCollection(right);
154-
}
155-
156-
private boolean isListCollection(Shape shape) {
157-
return shape.isListShape() || shape.isSetShape();
144+
return left instanceof SimpleShape && right instanceof SimpleShape;
158145
}
159146

160147
private void validateListCollectionReplacement(Model model, CollectionShape left, CollectionShape right) {

0 commit comments

Comments
 (0)