EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { @Override public boolean equals(Object obj) { boolean equals = false; if (obj == this) { equals = true; } else if (obj instanceof EntityReference) { EntityReference entityReference = (EntityReference) obj; equals = (entityReference.getName() == null ? getName() == null : entityReference.getName().equals(getName())) && (entityReference.getParent() == null ? getParent() == null : entityReference.getParent().equals( getParent())) && (entityReference.getType() == null ? getType() == null : entityReference.getType().equals( getType())); } return equals; } EntityReference(String name, EntityType type);  EntityReference(String name, EntityType type, EntityReference parent); void setName(String name); String getName(); void setParent(EntityReference parent); EntityReference getParent(); void setChild(EntityReference child); EntityReference getChild(); void setType(EntityType type); EntityType getType(); EntityReference getRoot(); EntityReference extractReference(EntityType type); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); @Override EntityReference clone(); int compareTo(EntityReference reference);  }
@Test public void testEquals() { EntityReference reference1 = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI))); Assert.assertEquals(reference1, reference1); EntityReference reference2 = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI))); Assert.assertEquals(reference1, reference2); EntityReference reference3 = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki2", EntityType.WIKI))); Assert.assertFalse(reference1.equals(reference3)); EntityReference reference4 = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space2", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI))); Assert.assertFalse(reference1.equals(reference4)); EntityReference reference5 = new EntityReference("page2", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI))); Assert.assertFalse(reference1.equals(reference5)); EntityReference reference6 = new EntityReference("page", EntityType.DOCUMENT, null); Assert.assertFalse(reference1.equals(reference6)); Assert.assertEquals(reference6, new EntityReference("page", EntityType.DOCUMENT, null)); }