@Override
        @SuppressWarnings("unchecked")
        public B flattenMixins() {
            if (getMixins().isEmpty()) {
                return (B) this;
            }

            Set<ShapeId> flatResources = new LinkedHashSet<>();
            Set<ShapeId> flatOperations = new LinkedHashSet<>();

            for (Shape shape : getMixins().values()) {
                EntityShape mixin = (EntityShape) shape;
                flatResources.addAll(mixin.getResources());
                flatOperations.addAll(mixin.getOperations());
            }

            flatResources.addAll(resources.peek());
            flatOperations.addAll(operations.peek());
            resources(flatResources);
            operations(flatOperations);

            return super.flattenMixins();
        }
Builder used to create a Service or Resource shape.
@param <B> Concrete builder type.
@param <S> Shape type being created.
smithy-model/src/main/java/software/amazon/smithy/model/shapes/EntityShape.java