org.maplibre.geojson.GeometryAdapterFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android-sdk-geojson Show documentation
Show all versions of android-sdk-geojson Show documentation
MapLibre Android Java Utilities
package org.maplibre.geojson;
import androidx.annotation.Keep;
import com.google.gson.TypeAdapterFactory;
import org.maplibre.geojson.internal.typeadapters.RuntimeTypeAdapterFactory;
/**
* A Geometry type adapter factory for convenience for serialization/deserialization.
* @since 4.6.0
*/
@Keep
public abstract class GeometryAdapterFactory implements TypeAdapterFactory {
private static TypeAdapterFactory geometryTypeFactory;
/**
* Create a new instance of Geometry type adapter factory, this is passed into the Gson
* Builder.
*
* @return a new GSON TypeAdapterFactory
* @since 4.4.0
*/
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;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy