1 package org.geojson; 2 3 /** 4 * Visitor to handle all different types of {@link GeoJsonObject}. 5 * 6 * @param <T> 7 * return type of the visitor. 8 */ 9 public interface GeoJsonObjectVisitor<T> { 10 visit(GeometryCollection geoJsonObject)11 T visit(GeometryCollection geoJsonObject); 12 visit(FeatureCollection geoJsonObject)13 T visit(FeatureCollection geoJsonObject); 14 visit(Point geoJsonObject)15 T visit(Point geoJsonObject); 16 visit(Feature geoJsonObject)17 T visit(Feature geoJsonObject); 18 visit(MultiLineString geoJsonObject)19 T visit(MultiLineString geoJsonObject); 20 visit(Polygon geoJsonObject)21 T visit(Polygon geoJsonObject); 22 visit(MultiPolygon geoJsonObject)23 T visit(MultiPolygon geoJsonObject); 24 visit(MultiPoint geoJsonObject)25 T visit(MultiPoint geoJsonObject); 26 visit(LineString geoJsonObject)27 T visit(LineString geoJsonObject); 28 29 /** 30 * An abstract adapter class for visiting GeoJson objects. 31 * The methods in this class are empty. 32 * This class exists as convenience for creating listener objects. 33 * 34 * @param <T> Return type of the visitor 35 */ 36 class Adapter<T> implements GeoJsonObjectVisitor<T> { 37 38 @Override visit(GeometryCollection geoJsonObject)39 public T visit(GeometryCollection geoJsonObject) { 40 return null; 41 } 42 43 @Override visit(FeatureCollection geoJsonObject)44 public T visit(FeatureCollection geoJsonObject) { 45 return null; 46 } 47 48 @Override visit(Point geoJsonObject)49 public T visit(Point geoJsonObject) { 50 return null; 51 } 52 53 @Override visit(Feature geoJsonObject)54 public T visit(Feature geoJsonObject) { 55 return null; 56 } 57 58 @Override visit(MultiLineString geoJsonObject)59 public T visit(MultiLineString geoJsonObject) { 60 return null; 61 } 62 63 @Override visit(Polygon geoJsonObject)64 public T visit(Polygon geoJsonObject) { 65 return null; 66 } 67 68 @Override visit(MultiPolygon geoJsonObject)69 public T visit(MultiPolygon geoJsonObject) { 70 return null; 71 } 72 73 @Override visit(MultiPoint geoJsonObject)74 public T visit(MultiPoint geoJsonObject) { 75 return null; 76 } 77 78 @Override visit(LineString geoJsonObject)79 public T visit(LineString geoJsonObject) { 80 return null; 81 } 82 } 83 } 84