package org.wololo.geojson;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public abstract class GeoJSON {
    private static final ObjectMapper mapper = new ObjectMapper();
    
    @JsonProperty("type")
    private String type;
    
    @JsonCreator
    public GeoJSON() {
        setType(getClass().getSimpleName());
    }
    
    public String toString() {
        try {
            return mapper.writeValueAsString(this);
        } catch (JsonGenerationException e) {
            return "Unhandled exception occured when serializing this instance";
        } catch (JsonMappingException e) {
            return "Unhandled exception occured when serializing this instance";
        } catch (IOException e) {
            return "Unhandled exception occured when serializing this instance";
        }
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}

@@ -47,24 +47,132 @@
 Exception;%0A%0A
+import com.fasterxml.jackson.annotation.JsonSubTypes;%0Aimport com.fasterxml.jackson.annotation.JsonTypeInfo;%0A
 import com.f
@@ -210,32 +210,32 @@
 ationException;%0A
-
 import com.faste
@@ -437,17 +437,846 @@
 Mapper;%0A
+@JsonTypeInfo(%0A        use = JsonTypeInfo.Id.NAME,%0A        include = JsonTypeInfo.As.EXISTING_PROPERTY,%0A        property = %22type%22%0A)%0A@JsonSubTypes( %7B%0A        @JsonSubTypes.Type(value=Point.class, name=%22Point%22  ),%0A        @JsonSubTypes.Type(value=LineString.class, name=%22LineString%22  ),%0A        @JsonSubTypes.Type(value=Polygon.class, name=%22Polygon%22  ),%0A        @JsonSubTypes.Type(value=MultiPoint.class, name=%22MultiPoint%22  ),%0A        @JsonSubTypes.Type(value=MultiLineString.class, name=%22MultiLineString%22  ),%0A        @JsonSubTypes.Type(value=MultiPolygon.class, name=%22MultiPolygon%22  ),%0A        @JsonSubTypes.Type(value=Feature.class, name=%22Feature%22  ),%0A        @JsonSubTypes.Type(value=FeatureCollection.class, name=%22FeatureCollection%22  ),%0A        @JsonSubTypes.Type(value=GeometryCollection.class, name=%22GeometryCollection%22  )%0A%7D)
 %0A
-
 public a
@@ -1366,21 +1366,17 @@
 pper();%0A
-    
 %0A
+
     @Jso
@@ -1418,21 +1418,17 @@
 g type;%0A
-    
 %0A
+
     @Jso
@@ -1510,20 +1510,16 @@
 ;%0A    %7D%0A
-    
 %0A    pub

fix "Cannot construct instance of `org.wololo.geojson.GeoJSON`"