public static TypeAdapterFactory create ( ) { if ( geometryTypeFactory == null ) { geometryTypeFactory = RuntimeTypeAdapterFactory . of ( Geometry . class , "type" , true ) . registerSubtype ( GeometryCollection . class , "GeometryCollection" ) . registerSubtype ( Point . class , "Point" ) . registerSubtype ( MultiPoint . class , "MultiPoint" ) . registerSubtype ( LineString . class , "LineString" ) . registerSubtype ( MultiLineString . class , "MultiLineString" ) . registerSubtype ( Polygon . class , "Polygon" ) . registerSubtype ( MultiPolygon . class , "MultiPolygon" ) ; } return geometryTypeFactory ; }
Create a new instance of Geometry type adapter factory this is passed into the Gson Builder .