Location { @Override public boolean equals(Object obj) { if (obj instanceof Location) { Location other = (Location) obj; return line == other.line && column == other.column; } return false; } Location(int line, int column); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); final int line; final int column; }
@Test public void testEquals() { ObjectTester.assertEqual(new Location(1, 2), new Location(1, 2)); ObjectTester.assertNotEqual(new Location(1, 2), new Location(2, 2), new Location(1, 1)); }