FeatureCollection implements GeoJson { public static FeatureCollection fromJson(@NonNull String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); gson.registerTypeAdapterFactory(GeometryAdapterFactory.create()); return gson.create().fromJson(json, FeatureCollection.class); } FeatureCollection(String type, @Nullable BoundingBox bbox, @Nullable List<Feature> features); static FeatureCollection fromJson(@NonNull String json); static FeatureCollection fromFeatures(@NonNull Feature[] features); static FeatureCollection fromFeatures(@NonNull List<Feature> features); static FeatureCollection fromFeatures(@NonNull Feature[] features,
                                               @Nullable BoundingBox bbox); static FeatureCollection fromFeatures(@NonNull List<Feature> features,
                                               @Nullable BoundingBox bbox); static FeatureCollection fromFeature(@NonNull Feature feature); static FeatureCollection fromFeature(@NonNull Feature feature,
                                              @Nullable BoundingBox bbox); @NonNull @Override String type(); @Nullable @Override BoundingBox bbox(); @Nullable List<Feature> features(); @Override String toJson(); static TypeAdapter<FeatureCollection> typeAdapter(Gson gson); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void fromJson() throws IOException { final String json = loadJsonFixture(SAMPLE_FEATURECOLLECTION); FeatureCollection geo = FeatureCollection.fromJson(json); assertEquals(geo.type(), "FeatureCollection"); assertEquals(geo.features().size(), 3); assertEquals(geo.features().get(0).type(), "Feature"); assertEquals(geo.features().get(0).geometry().type(), "Point"); assertEquals(geo.features().get(1).type(), "Feature"); assertEquals(geo.features().get(1).geometry().type(), "LineString"); assertEquals(geo.features().get(2).type(), "Feature"); assertEquals(geo.features().get(2).geometry().type(), "Polygon"); }