1 package org.geojson; 2 3 import java.util.ArrayList; 4 import java.util.Iterator; 5 import java.util.List; 6 7 public class GeometryCollection extends GeoJsonObject implements Iterable<GeoJsonObject> { 8 9 private List<GeoJsonObject> geometries = new ArrayList<GeoJsonObject>(); 10 getGeometries()11 public List<GeoJsonObject> getGeometries() { 12 return geometries; 13 } 14 setGeometries(List<GeoJsonObject> geometries)15 public void setGeometries(List<GeoJsonObject> geometries) { 16 this.geometries = geometries; 17 } 18 19 @Override iterator()20 public Iterator<GeoJsonObject> iterator() { 21 return geometries.iterator(); 22 } 23 add(GeoJsonObject geometry)24 public GeometryCollection add(GeoJsonObject geometry) { 25 geometries.add(geometry); 26 return this; 27 } 28 29 @Override accept(GeoJsonObjectVisitor<T> geoJsonObjectVisitor)30 public <T> T accept(GeoJsonObjectVisitor<T> geoJsonObjectVisitor) { 31 return geoJsonObjectVisitor.visit(this); 32 } 33 34 @Override equals(Object o)35 public boolean equals(Object o) { 36 if (this == o) 37 return true; 38 if (!(o instanceof GeometryCollection)) 39 return false; 40 if (!super.equals(o)) 41 return false; 42 GeometryCollection that = (GeometryCollection)o; 43 return !(geometries != null ? !geometries.equals(that.geometries) : that.geometries != null); 44 } 45 46 @Override hashCode()47 public int hashCode() { 48 int result = super.hashCode(); 49 result = 31 * result + (geometries != null ? geometries.hashCode() : 0); 50 return result; 51 } 52 53 @Override toString()54 public String toString() { 55 return "GeometryCollection{" + "geometries=" + geometries + "} " + super.toString(); 56 } 57 } 58