Identifier implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Identifier other = (Identifier) obj; if (id == null) { if (other.id != null) { return false; } } else if (!id.equals(other.id)) { return false; } return true; } protected  Identifier(final String prefix, byte[] data); protected  Identifier(final String prefix, final Digest digest); String asXmlId(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testEquals() { byte[] bytes = new byte[] { 1, 2, 3, 4, 5, 6 }; byte[] bytes2 = new byte[] { 1, 2, 3, 5, 5, 6 }; MockIdentifier t1 = new MockIdentifier(bytes); MockIdentifier t2 = new MockIdentifier(bytes); MockIdentifier t3 = new MockIdentifier(bytes2); assertEquals(t1, t2); assertNotEquals(t1, t3); String id1 = t1.asXmlId(); String id2 = t2.asXmlId(); String id3 = t3.asXmlId(); assertEquals(id1, id2); assertNotEquals(id2, id3); }