Point implements Comparable<Point>, Cloneable, Position { @Override public int compareTo(final Point other) { if (this == other) { return 0; } if (this.latitude < other.latitude) { return -1; } if (this.latitude > other.latitude) { return 1; } if (this.longitude < other.longitude) { return -1; } if (this.longitude > other.longitude) { return 1; } assert this.equals(other) : "compareTo inconsistent with equals."; return 0; } Point(final double latitude, final double longitude); @Override Object clone(); @Override int compareTo(final Point other); @Override double getLatitude(); @Override double getLongitude(); @Override void setLatitude(final double latitude); @Override void setLongitude(final double longitude); @Override String toString();  }
@Test public void testCompareTo() { boolean expected; int actual; String geohash; Point o1; Point o2; geohash = GeoHashExtensions.encode(53.5526394, 10.0067103); o1 = new GeoHashPoint(geohash); o2 = new GeoHashPoint(geohash); actual = o1.compareTo(o2); expected = actual == 0; assertTrue(expected); actual = o1.compareTo(o1); expected = actual == 0; assertTrue(expected); geohash = GeoHashExtensions.encode(30.0, -90.0); o2 = new GeoHashPoint(geohash); actual = o1.compareTo(o2); expected = 0 < actual; assertTrue(expected); actual = o2.compareTo(o1); expected = actual < 0; assertTrue(expected); }