S2Point implements Point<Sphere2D> { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other instanceof S2Point) { final S2Point rhs = (S2Point) other; if (rhs.isNaN()) { return this.isNaN(); } return (theta == rhs.theta) && (phi == rhs.phi); } return false; } S2Point(final double theta, final double phi);  S2Point(final Vector3D vector); private  S2Point(final double theta, final double phi, final Vector3D vector); double getTheta(); double getPhi(); Vector3D getVector(); Space getSpace(); boolean isNaN(); S2Point negate(); double distance(final Point<Sphere2D> point); static double distance(S2Point p1, S2Point p2); @Override boolean equals(Object other); @Override int hashCode(); static final S2Point PLUS_I; static final S2Point PLUS_J; static final S2Point PLUS_K; static final S2Point MINUS_I; static final S2Point MINUS_J; static final S2Point MINUS_K; static final S2Point NaN; }
@Test public void testEquals() { S2Point a = new S2Point(1.0, 1.0); S2Point b = new S2Point(1.0, 1.0); Assert.assertEquals(a.hashCode(), b.hashCode()); Assert.assertFalse(a == b); Assert.assertTrue(a.equals(b)); Assert.assertTrue(a.equals(a)); Assert.assertFalse(a.equals('a')); }