diff --git a/build.gradle b/build.gradle index 9d934e30a..2b36ecff7 100644 --- a/build.gradle +++ b/build.gradle @@ -49,8 +49,8 @@ subprojects { } } - sourceCompatibility = "1.8" - targetCompatibility = "1.8" + sourceCompatibility = JavaVersion.VERSION_1_7 + targetCompatibility = JavaVersion.VERSION_1_7 dependencies { diff --git a/services-directions/src/test/java/com/mapbox/api/directions/v5/models/RouteLegTest.java b/services-directions/src/test/java/com/mapbox/api/directions/v5/models/RouteLegTest.java index 5aec1432f..4ef7e3022 100644 --- a/services-directions/src/test/java/com/mapbox/api/directions/v5/models/RouteLegTest.java +++ b/services-directions/src/test/java/com/mapbox/api/directions/v5/models/RouteLegTest.java @@ -71,6 +71,8 @@ public void testToFromJson1() { "heavy", "heavy"); + List steps = new ArrayList<>(); + LegAnnotation annotation = LegAnnotation.builder() .congestion(new ArrayList()) .distance(distanceList) @@ -84,7 +86,7 @@ public void testToFromJson1() { .distance(53.4) //.weight(14.3) .duration(14.3) - .steps(new ArrayList<>()) + .steps(steps) .summary("") .build(); diff --git a/services-geojson/src/main/java/com/mapbox/geojson/Geometry.java b/services-geojson/src/main/java/com/mapbox/geojson/Geometry.java index ce1f418a4..ad792377f 100644 --- a/services-geojson/src/main/java/com/mapbox/geojson/Geometry.java +++ b/services-geojson/src/main/java/com/mapbox/geojson/Geometry.java @@ -1,12 +1,5 @@ package com.mapbox.geojson; -import android.support.annotation.NonNull; - -import com.google.gson.GsonBuilder; -import com.mapbox.geojson.gson.GeoJsonAdapterFactory; -import com.mapbox.geojson.gson.GeometryDeserializer; -import com.mapbox.geojson.gson.PointDeserializer; - /** * Each of the six geometries and {@link GeometryCollection} * which make up GeoJson implement this interface. @@ -15,20 +8,4 @@ */ public interface Geometry extends GeoJson { - /** - * Create a new instance of this class by passing in a formatted valid JSON String. - * - * @param json a formatted valid JSON string defining a GeoJson Geometry - * @return a new instance of this class defined by the values passed inside this static factory - * method - * @since 3.0.0 - */ - static Geometry fromJson(@NonNull String json) { - GsonBuilder gson = new GsonBuilder(); - gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); - gson.registerTypeAdapter(Point.class, new PointDeserializer()); - gson.registerTypeAdapter(Geometry.class, new GeometryDeserializer()); - return gson.create().fromJson(json, Geometry.class); - } - } diff --git a/services-geojson/src/main/java/com/mapbox/geojson/gson/GeometryGeoJson.java b/services-geojson/src/main/java/com/mapbox/geojson/gson/GeometryGeoJson.java new file mode 100644 index 000000000..4fa32907d --- /dev/null +++ b/services-geojson/src/main/java/com/mapbox/geojson/gson/GeometryGeoJson.java @@ -0,0 +1,30 @@ +package com.mapbox.geojson.gson; + +import android.support.annotation.NonNull; + +import com.google.gson.GsonBuilder; +import com.mapbox.geojson.Geometry; +import com.mapbox.geojson.Point; + +/** + * This is a utility class that helps create a Geometry instance from a JSON string. + * @since 3.5.0 + */ +public class GeometryGeoJson { + + /** + * Create a new instance of Geometry class by passing in a formatted valid JSON String. + * + * @param json a formatted valid JSON string defining a GeoJson Geometry + * @return a new instance of Geometry class defined by the values passed inside + * this static factory method + * @since 3.5.0 + */ + public static Geometry fromJson(@NonNull String json) { + GsonBuilder gson = new GsonBuilder(); + gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create()); + gson.registerTypeAdapter(Point.class, new PointDeserializer()); + gson.registerTypeAdapter(Geometry.class, new GeometryDeserializer()); + return gson.create().fromJson(json, Geometry.class); + } +} diff --git a/services-geojson/src/test/java/com/mapbox/geojson/GeometryTest.java b/services-geojson/src/test/java/com/mapbox/geojson/GeometryTest.java index 3d9fd0dd2..f4e8bfc12 100644 --- a/services-geojson/src/test/java/com/mapbox/geojson/GeometryTest.java +++ b/services-geojson/src/test/java/com/mapbox/geojson/GeometryTest.java @@ -1,6 +1,7 @@ package com.mapbox.geojson; import com.mapbox.core.TestUtils; +import com.mapbox.geojson.gson.GeometryGeoJson; import org.junit.Test; @@ -15,7 +16,7 @@ public class GeometryTest extends TestUtils { @Test public void fromJson() throws IOException { final String json = loadJsonFixture(SAMPLE_GEOMETRY_COLLECTION); - Geometry geo = Geometry.fromJson(json); + Geometry geo = GeometryGeoJson.fromJson(json); assertEquals(geo.type(), "GeometryCollection"); } }