@Override
    public int size() {
        // Computing the size of the set is O(N) because we need to iterate
        // over every value and test if it's of the right type. The size is
        // cached to avoid doing this repeatedly.
        int result = size;

        if (result == -1) {
            result = 0;
            for (Shape shape : shapes) {
                if (shapeType == shape.getClass()) {
                    result++;
                }
            }
            size = result;
        }

        return result;
    }
Provides a view of a set returned by the getXwithTrait methods so that only
shapes of a specific type are treated as present within the set.

@param <T> Type of shape to project out of the Set.
smithy-model/src/main/java/software/amazon/smithy/model/ShapeTypeFilteredSet.java