@Test public void compareToTest() { LatLong latLong1 = new LatLong(LATITUDE, LONGITUDE); LatLong latLong2 = new LatLong(LATITUDE, LONGITUDE); LatLong latLong3 = new LatLong(LATITUDE, LATITUDE); LatLong latLong4 = new LatLong(LONGITUDE, LONGITUDE); Assert.assertEquals(0, latLong1.compareTo(latLong2)); TestUtils.notCompareToTest(latLong1, latLong3); TestUtils.notCompareToTest(latLong1, latLong4); }
@Override public int compareTo(LatLong latLong) { if (this.longitude > latLong.longitude) { return 1; } else if (this.longitude < latLong.longitude) { return -1; } else if (this.latitude > latLong.latitude) { return 1; } else if (this.latitude < latLong.latitude) { return -1; } return 0; }
LatLong implements Comparable<LatLong>, Serializable { @Override public int compareTo(LatLong latLong) { if (this.longitude > latLong.longitude) { return 1; } else if (this.longitude < latLong.longitude) { return -1; } else if (this.latitude > latLong.latitude) { return 1; } else if (this.latitude < latLong.latitude) { return -1; } return 0; } }
LatLong implements Comparable<LatLong>, Serializable { @Override public int compareTo(LatLong latLong) { if (this.longitude > latLong.longitude) { return 1; } else if (this.longitude < latLong.longitude) { return -1; } else if (this.latitude > latLong.latitude) { return 1; } else if (this.latitude < latLong.latitude) { return -1; } return 0; } LatLong(double latitude, double longitude); }
LatLong implements Comparable<LatLong>, Serializable { @Override public int compareTo(LatLong latLong) { if (this.longitude > latLong.longitude) { return 1; } else if (this.longitude < latLong.longitude) { return -1; } else if (this.latitude > latLong.latitude) { return 1; } else if (this.latitude < latLong.latitude) { return -1; } return 0; } LatLong(double latitude, double longitude); @Override int compareTo(LatLong latLong); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
LatLong implements Comparable<LatLong>, Serializable { @Override public int compareTo(LatLong latLong) { if (this.longitude > latLong.longitude) { return 1; } else if (this.longitude < latLong.longitude) { return -1; } else if (this.latitude > latLong.latitude) { return 1; } else if (this.latitude < latLong.latitude) { return -1; } return 0; } LatLong(double latitude, double longitude); @Override int compareTo(LatLong latLong); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); final double latitude; final double longitude; }