PlainFeatureFactory { public static SimpleFeatureType createPlainFeatureType(String typeName, Class<? extends Geometry> geometryType, CoordinateReferenceSystem crs) { SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder(); AttributeTypeBuilder atb = new AttributeTypeBuilder(); if (crs != null) { atb.setCRS(crs); } atb.setBinding(geometryType); atb.nillable(false); sftb.add(atb.buildDescriptor(ATTRIB_NAME_GEOMETRY)); sftb.setDefaultGeometry(ATTRIB_NAME_GEOMETRY); atb.setBinding(String.class); atb.nillable(true); sftb.add(atb.buildDescriptor(ATTRIB_NAME_STYLE_CSS)); sftb.setName(typeName); return sftb.buildFeatureType(); }  static SimpleFeatureType createDefaultFeatureType(); static SimpleFeatureType createDefaultFeatureType(CoordinateReferenceSystem crs); static SimpleFeatureType createPlainFeatureType(String typeName,
                                                           Class<? extends Geometry> geometryType,
                                                           CoordinateReferenceSystem crs); static SimpleFeature createPlainFeature(SimpleFeatureType type, String id, Geometry geometry, String styleCSS); static final String DEFAULT_TYPE_NAME; static final String ATTRIB_NAME_GEOMETRY; static final String ATTRIB_NAME_STYLE_CSS; }
@Test public void testPlainFeatureType() { SimpleFeatureType sft = PlainFeatureFactory.createPlainFeatureType("MyPoint", Point.class, DefaultGeographicCRS.WGS84); assertEquals("MyPoint", sft.getTypeName()); assertNotNull(sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_GEOMETRY)); assertFalse(sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_GEOMETRY).isNillable()); assertNull(sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_GEOMETRY).getDefaultValue()); assertEquals(Point.class, sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_GEOMETRY).getType().getBinding()); assertNotNull(sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_STYLE_CSS)); assertTrue(sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_STYLE_CSS).isNillable()); assertNull(sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_STYLE_CSS).getDefaultValue()); assertSame(sft.getGeometryDescriptor(), sft.getDescriptor(PlainFeatureFactory.ATTRIB_NAME_GEOMETRY)); assertNotNull(sft.getGeometryDescriptor().getType()); assertSame(DefaultGeographicCRS.WGS84, sft.getCoordinateReferenceSystem()); assertSame(DefaultGeographicCRS.WGS84, sft.getGeometryDescriptor().getCoordinateReferenceSystem()); assertSame(DefaultGeographicCRS.WGS84, sft.getGeometryDescriptor().getType().getCoordinateReferenceSystem()); }