@Override public Shape build() { List<Shape> shapes = new ArrayList<>(this.shapes.size()); for (ShapeBuilder shape : this.shapes) { shapes.add(shape.build()); } if (shapes.size() == 1) return shapes.get(0); else return new XShapeCollection<>(shapes, SPATIAL_CONTEXT); // note: ShapeCollection is probably faster than a Multi* geom. }