diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/shapes/ShapeVisitor.java b/smithy-model/src/main/java/software/amazon/smithy/model/shapes/ShapeVisitor.java index 6a62ba74709..b36c616f20d 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/shapes/ShapeVisitor.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/shapes/ShapeVisitor.java @@ -199,4 +199,30 @@ public R timestampShape(TimestampShape shape) { return getDefault(shape); } } + + /** + * Creates {@link ShapeVisitor} that only requires implementation of + * all data shape branches, but does not support service shapes. + * + * @param Return type. + */ + abstract class DataShapeVisitor implements ShapeVisitor { + @Override + public R operationShape(OperationShape shape) { + throw new IllegalArgumentException("DataShapeVisitor cannot be use to visit " + + "Operation Shapes. Attempted to visit: " + shape); + } + + @Override + public R resourceShape(ResourceShape shape) { + throw new IllegalArgumentException("DataShapeVisitor cannot be use to visit " + + "Resource Shapes. Attempted to visit: " + shape); + } + + @Override + public R serviceShape(ServiceShape shape) { + throw new IllegalArgumentException("DataShapeVisitor cannot be use to visit " + + "Service Shapes. Attempted to visit: " + shape); + } + } }