@Test public void testEquals() { GeoPoint foo = gp(1.23, 4.56); GeoPoint fooDup = gp(1.23, 4.56); GeoPoint differentLatitude = gp(0, 4.56); GeoPoint differentLongitude = gp(1.23, 0); assertEquals(foo, fooDup); assertNotEquals(foo, differentLatitude); assertNotEquals(foo, differentLongitude); assertEquals(foo.hashCode(), fooDup.hashCode()); assertNotEquals(foo.hashCode(), differentLatitude.hashCode()); assertNotEquals(foo.hashCode(), differentLongitude.hashCode()); }
@Override public boolean equals(@Nullable Object o) { if (!(o instanceof GeoPoint)) { return false; } GeoPoint geoPoint = (GeoPoint) o; return latitude == geoPoint.latitude && longitude == geoPoint.longitude; }
GeoPoint implements Comparable<GeoPoint> { @Override public boolean equals(@Nullable Object o) { if (!(o instanceof GeoPoint)) { return false; } GeoPoint geoPoint = (GeoPoint) o; return latitude == geoPoint.latitude && longitude == geoPoint.longitude; } }
GeoPoint implements Comparable<GeoPoint> { @Override public boolean equals(@Nullable Object o) { if (!(o instanceof GeoPoint)) { return false; } GeoPoint geoPoint = (GeoPoint) o; return latitude == geoPoint.latitude && longitude == geoPoint.longitude; } GeoPoint(double latitude, double longitude); }
GeoPoint implements Comparable<GeoPoint> { @Override public boolean equals(@Nullable Object o) { if (!(o instanceof GeoPoint)) { return false; } GeoPoint geoPoint = (GeoPoint) o; return latitude == geoPoint.latitude && longitude == geoPoint.longitude; } GeoPoint(double latitude, double longitude); double getLatitude(); double getLongitude(); @Override int compareTo(@NonNull GeoPoint other); @Override @NonNull String toString(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); }
GeoPoint implements Comparable<GeoPoint> { @Override public boolean equals(@Nullable Object o) { if (!(o instanceof GeoPoint)) { return false; } GeoPoint geoPoint = (GeoPoint) o; return latitude == geoPoint.latitude && longitude == geoPoint.longitude; } GeoPoint(double latitude, double longitude); double getLatitude(); double getLongitude(); @Override int compareTo(@NonNull GeoPoint other); @Override @NonNull String toString(); @Override boolean equals(@Nullable Object o); @Override int hashCode();  }