@Test public void equalsTest() { LatLong latLong1 = new LatLong(LATITUDE, LONGITUDE); LatLong latLong2 = new LatLong(LATITUDE, LONGITUDE); LatLong latLong3 = new LatLong(LATITUDE, LATITUDE); LatLong latLong4 = new LatLong(LONGITUDE, LONGITUDE); TestUtils.equalsTest(latLong1, latLong2); TestUtils.notEqualsTest(latLong1, latLong3); TestUtils.notEqualsTest(latLong1, latLong4); TestUtils.notEqualsTest(latLong1, new Object()); TestUtils.notEqualsTest(latLong1, null); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof LatLong)) { return false; } LatLong other = (LatLong) obj; if (Double.doubleToLongBits(this.latitude) != Double.doubleToLongBits(other.latitude)) { return false; } else if (Double.doubleToLongBits(this.longitude) != Double.doubleToLongBits(other.longitude)) { return false; } return true; }
LatLong implements Comparable<LatLong>, Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof LatLong)) { return false; } LatLong other = (LatLong) obj; if (Double.doubleToLongBits(this.latitude) != Double.doubleToLongBits(other.latitude)) { return false; } else if (Double.doubleToLongBits(this.longitude) != Double.doubleToLongBits(other.longitude)) { return false; } return true; } }
LatLong implements Comparable<LatLong>, Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof LatLong)) { return false; } LatLong other = (LatLong) obj; if (Double.doubleToLongBits(this.latitude) != Double.doubleToLongBits(other.latitude)) { return false; } else if (Double.doubleToLongBits(this.longitude) != Double.doubleToLongBits(other.longitude)) { return false; } return true; } LatLong(double latitude, double longitude); }
LatLong implements Comparable<LatLong>, Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof LatLong)) { return false; } LatLong other = (LatLong) obj; if (Double.doubleToLongBits(this.latitude) != Double.doubleToLongBits(other.latitude)) { return false; } else if (Double.doubleToLongBits(this.longitude) != Double.doubleToLongBits(other.longitude)) { return false; } return true; } 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 boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof LatLong)) { return false; } LatLong other = (LatLong) obj; if (Double.doubleToLongBits(this.latitude) != Double.doubleToLongBits(other.latitude)) { return false; } else if (Double.doubleToLongBits(this.longitude) != Double.doubleToLongBits(other.longitude)) { return false; } return true; } 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; }