Vertex { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Vertex other = (Vertex) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; return true; } Vertex(String id); String getId(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testEquals() throws Exception { id = "test"; vertex = new Vertex(id); Vertex vertex1 = new Vertex("test1"); Assert.assertTrue(vertex1.equals(vertex1)); Assert.assertFalse(vertex1.equals(vertex)); }