SimpleFeatureTypeBuilder builder;
builder = new SimpleFeatureTypeBuilder();
builder.setName(typeName);
List<AttributeDescriptor> attributes = prototype.getAttributeDescriptors();
GeometryDescriptor defaultGeomAttr = prototype.getGeometryDescriptor();
assert defaultGeomAttr != null : "default geometry was expected"; //$NON-NLS-1$
// adds all attributes without default geometry
for (int i = 0; i < attributes.size(); i++) {
AttributeDescriptor att = attributes.get(i);
if (att != defaultGeomAttr) {
builder.add(att);
}
}
// create the default geometry with Geometry Class value
AttributeTypeBuilder build = new AttributeTypeBuilder();
build.setName(defaultGeomAttr.getLocalName());
build.setNillable(true);
build.setBinding(geometryClass);
build.setCRS(crs);
GeometryType type = build.buildGeometryType();
builder.setDefaultGeometry(build.buildDescriptor(defaultGeomAttr.getLocalName(), type).getLocalName());
builder.add(defaultGeomAttr.getLocalName(), geometryClass, crs);
return builder.buildFeatureType();
}