Skip to content

Commit

Permalink
Add data-shape-only visitor class (#2168)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpmellema committed Feb 28, 2024
1 parent ba09aa4 commit e9cca36
Showing 1 changed file with 26 additions and 0 deletions.
Expand Up @@ -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 <R> Return type.
*/
abstract class DataShapeVisitor<R> implements ShapeVisitor<R> {
@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);
}
}
}

0 comments on commit e9cca36

Please sign in to comment.