Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java 7 downgrade #876

Merged
merged 1 commit into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ subprojects {
}
}

sourceCompatibility = "1.8"
targetCompatibility = "1.8"
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public void testToFromJson1() {
"heavy",
"heavy");

List<LegStep> steps = new ArrayList<>();

LegAnnotation annotation = LegAnnotation.builder()
.congestion(new ArrayList<String>())
.distance(distanceList)
Expand All @@ -84,7 +86,7 @@ public void testToFromJson1() {
.distance(53.4)
//.weight(14.3)
.duration(14.3)
.steps(new ArrayList<>())
.steps(steps)
.summary("")
.build();

Expand Down
23 changes: 0 additions & 23 deletions services-geojson/src/main/java/com/mapbox/geojson/Geometry.java
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mapbox.geojson;

import com.mapbox.core.TestUtils;
import com.mapbox.geojson.gson.GeometryGeoJson;

import org.junit.Test;

Expand All @@ -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");
}
}