Point implements CoordinateContainer<List<Double>> { public static Point fromJson(@NonNull String json) { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); return gson.create().fromJson(json, Point.class); } Point(String type, @Nullable BoundingBox bbox, List<Double> coordinates); static Point fromJson(@NonNull String json); static Point fromLngLat(double longitude, double latitude); static Point fromLngLat(double longitude, double latitude,
    @Nullable BoundingBox bbox); static Point fromLngLat(double longitude, double latitude, double altitude); static Point fromLngLat(double longitude, double latitude,
    double altitude, @Nullable BoundingBox bbox); double longitude(); double latitude(); double altitude(); boolean hasAltitude(); @NonNull @Override String type(); @Nullable @Override BoundingBox bbox(); @NonNull @Override List<Double> coordinates(); @Override String toJson(); static TypeAdapter<Point> typeAdapter(Gson gson); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void fromJson() throws IOException { final String json = "{ \"type\": \"Point\", \"coordinates\": [ 100, 0] }"; Point geo = Point.fromJson(json); assertEquals(geo.type(), "Point"); assertEquals(geo.longitude(), 100.0, DELTA); assertEquals(geo.latitude(), 0.0, DELTA); assertEquals(geo.altitude(), Double.NaN, DELTA); assertEquals(geo.coordinates().get(0), 100.0, DELTA); assertEquals(geo.coordinates().get(1), 0.0, DELTA); assertEquals(geo.coordinates().size(), 2); assertFalse(geo.hasAltitude()); }
@Test public void fromJson_coordinatesPresent() throws Exception { thrown.expect(NullPointerException.class); Point.fromJson("{\"type\":\"Point\",\"coordinates\":null}"); }