20
20
import java .util .Collections ;
21
21
import java .util .List ;
22
22
23
- import org .springframework .data .geo .GeoModule ;
24
23
import org .springframework .data .geo .Point ;
25
24
26
25
import com .fasterxml .jackson .core .JsonParser ;
27
26
import com .fasterxml .jackson .core .JsonProcessingException ;
28
27
import com .fasterxml .jackson .databind .DeserializationContext ;
29
28
import com .fasterxml .jackson .databind .JsonDeserializer ;
30
29
import com .fasterxml .jackson .databind .JsonNode ;
30
+ import com .fasterxml .jackson .databind .JsonSerializer ;
31
+ import com .fasterxml .jackson .databind .Module ;
32
+ import com .fasterxml .jackson .databind .module .SimpleModule ;
31
33
import com .fasterxml .jackson .databind .node .ArrayNode ;
32
34
33
35
/**
36
+ * A Jackson {@link Module} to register custom {@link JsonSerializer} and {@link JsonDeserializer}s for GeoJSON types.
37
+ *
34
38
* @author Christoph Strobl
39
+ * @author Oliver Gierke
35
40
* @since 1.7
36
41
*/
37
- public class GeoJsonModule extends GeoModule {
42
+ public class GeoJsonModule extends SimpleModule {
43
+
44
+ private static final long serialVersionUID = -8723016728655643720L ;
38
45
39
46
public GeoJsonModule () {
40
- super ();
41
47
42
48
addDeserializer (GeoJsonPoint .class , new GeoJsonPointDeserializer ());
43
49
addDeserializer (GeoJsonMultiPoint .class , new GeoJsonMultiPointDeserializer ());
@@ -51,7 +57,7 @@ public GeoJsonModule() {
51
57
* @author Christoph Strobl
52
58
* @since 1.7
53
59
*/
54
- static abstract class GeoJsonDeserializer <T extends GeoJson <?>> extends JsonDeserializer <T > {
60
+ private static abstract class GeoJsonDeserializer <T extends GeoJson <?>> extends JsonDeserializer <T > {
55
61
56
62
/*
57
63
* (non-Javadoc)
@@ -148,7 +154,7 @@ protected GeoJsonLineString toLineString(ArrayNode node) {
148
154
* @author Christoph Strobl
149
155
* @since 1.7
150
156
*/
151
- static class GeoJsonPointDeserializer extends GeoJsonDeserializer <GeoJsonPoint > {
157
+ private static class GeoJsonPointDeserializer extends GeoJsonDeserializer <GeoJsonPoint > {
152
158
153
159
/*
154
160
* (non-Javadoc)
@@ -177,7 +183,7 @@ protected GeoJsonPoint doDeserialize(ArrayNode coordinates) {
177
183
* @author Christoph Strobl
178
184
* @since 1.7
179
185
*/
180
- static class GeoJsonLineStringDeserializer extends GeoJsonDeserializer <GeoJsonLineString > {
186
+ private static class GeoJsonLineStringDeserializer extends GeoJsonDeserializer <GeoJsonLineString > {
181
187
182
188
/*
183
189
* (non-Javadoc)
@@ -206,7 +212,7 @@ protected GeoJsonLineString doDeserialize(ArrayNode coordinates) {
206
212
* @author Christoph Strobl
207
213
* @since 1.7
208
214
*/
209
- static class GeoJsonMultiPointDeserializer extends GeoJsonDeserializer <GeoJsonMultiPoint > {
215
+ private static class GeoJsonMultiPointDeserializer extends GeoJsonDeserializer <GeoJsonMultiPoint > {
210
216
211
217
/*
212
218
* (non-Javadoc)
@@ -236,7 +242,7 @@ protected GeoJsonMultiPoint doDeserialize(ArrayNode coordinates) {
236
242
* @author Christoph Strobl
237
243
* @since 1.7
238
244
*/
239
- static class GeoJsonMultiLineStringDeserializer extends GeoJsonDeserializer <GeoJsonMultiLineString > {
245
+ private static class GeoJsonMultiLineStringDeserializer extends GeoJsonDeserializer <GeoJsonMultiLineString > {
240
246
241
247
/*
242
248
* (non-Javadoc)
@@ -248,7 +254,6 @@ protected GeoJsonMultiLineString doDeserialize(ArrayNode coordinates) {
248
254
List <GeoJsonLineString > lines = new ArrayList <GeoJsonLineString >(coordinates .size ());
249
255
250
256
for (JsonNode lineString : coordinates ) {
251
-
252
257
if (lineString .isArray ()) {
253
258
lines .add (toLineString ((ArrayNode ) lineString ));
254
259
}
@@ -275,7 +280,7 @@ protected GeoJsonMultiLineString doDeserialize(ArrayNode coordinates) {
275
280
* @author Christoph Strobl
276
281
* @since 1.7
277
282
*/
278
- static class GeoJsonPolygonDeserializer extends GeoJsonDeserializer <GeoJsonPolygon > {
283
+ private static class GeoJsonPolygonDeserializer extends GeoJsonDeserializer <GeoJsonPolygon > {
279
284
280
285
/*
281
286
* (non-Javadoc)
@@ -287,9 +292,9 @@ protected GeoJsonPolygon doDeserialize(ArrayNode coordinates) {
287
292
for (JsonNode ring : coordinates ) {
288
293
289
294
// currently we do not support holes in polygons.
290
- GeoJsonPolygon polygon = new GeoJsonPolygon (toPoints ((ArrayNode ) ring ));
291
- return polygon ;
295
+ return new GeoJsonPolygon (toPoints ((ArrayNode ) ring ));
292
296
}
297
+
293
298
return null ;
294
299
}
295
300
}
@@ -313,7 +318,7 @@ protected GeoJsonPolygon doDeserialize(ArrayNode coordinates) {
313
318
* @author Christoph Strobl
314
319
* @since 1.7
315
320
*/
316
- static class GeoJsonMultiPolygonDeserializer extends GeoJsonDeserializer <GeoJsonMultiPolygon > {
321
+ private static class GeoJsonMultiPolygonDeserializer extends GeoJsonDeserializer <GeoJsonMultiPolygon > {
317
322
318
323
/*
319
324
* (non-Javadoc)
0 commit comments