• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.geojson;
2 
3 import java.util.ArrayList;
4 import java.util.List;
5 
6 public abstract class Geometry<T> extends GeoJsonObject {
7 
8 	protected List<T> coordinates = new ArrayList<T>();
9 
Geometry()10 	public Geometry() {
11 	}
12 
Geometry(T... elements)13 	public Geometry(T... elements) {
14 		for (T coordinate : elements) {
15 			coordinates.add(coordinate);
16 		}
17 	}
18 
add(T elements)19 	public Geometry<T> add(T elements) {
20 		coordinates.add(elements);
21 		return this;
22 	}
23 
getCoordinates()24 	public List<T> getCoordinates() {
25 		return coordinates;
26 	}
27 
setCoordinates(List<T> coordinates)28 	public void setCoordinates(List<T> coordinates) {
29 		this.coordinates = coordinates;
30 	}
31 
32 	@SuppressWarnings("rawtypes")
33 	@Override
equals(Object o)34 	public boolean equals(Object o) {
35 		if (this == o) {
36 			return true;
37 		}
38 		if (!(o instanceof Geometry)) {
39 			return false;
40 		}
41 		if (!super.equals(o)) {
42 			return false;
43 		}
44 		Geometry geometry = (Geometry)o;
45 		return !(coordinates != null ? !coordinates.equals(geometry.coordinates) : geometry.coordinates != null);
46 	}
47 
48 	@Override
hashCode()49 	public int hashCode() {
50 		int result = super.hashCode();
51 		result = 31 * result + (coordinates != null ? coordinates.hashCode() : 0);
52 		return result;
53 	}
54 
55 	@Override
toString()56 	public String toString() {
57 		return "Geometry{" + "coordinates=" + coordinates + "} " + super.toString();
58 	}
59 }
60