Skip to content

Commit

Permalink
Add data-shape-only visitor class
Browse files Browse the repository at this point in the history
  • Loading branch information
hpmellema committed Feb 28, 2024
1 parent 367c4a5 commit 0d063dc
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
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 0d063dc

Please sign in to comment.