@Test public void testClone() { EntityReference reference = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI))); EntityReference clonedReference = reference.clone(); Assert.assertNotSame(reference, clonedReference); Assert.assertNotSame(reference.getParent(), clonedReference.getParent()); Assert.assertNotSame(reference.getParent().getParent(), clonedReference.getParent().getParent()); Assert.assertEquals(reference, clonedReference); }
@Override public EntityReference clone() { EntityReference reference; try { reference = (EntityReference) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException("Failed to clone object", e); } reference.setName(getName()); reference.setType(getType()); if (getParent() != null) { reference.setParent(getParent().clone()); } return reference; }
EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { @Override public EntityReference clone() { EntityReference reference; try { reference = (EntityReference) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException("Failed to clone object", e); } reference.setName(getName()); reference.setType(getType()); if (getParent() != null) { reference.setParent(getParent().clone()); } return reference; } }
EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { @Override public EntityReference clone() { EntityReference reference; try { reference = (EntityReference) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException("Failed to clone object", e); } reference.setName(getName()); reference.setType(getType()); if (getParent() != null) { reference.setParent(getParent().clone()); } return reference; } EntityReference(String name, EntityType type);  EntityReference(String name, EntityType type, EntityReference parent); }
EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { @Override public EntityReference clone() { EntityReference reference; try { reference = (EntityReference) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException("Failed to clone object", e); } reference.setName(getName()); reference.setType(getType()); if (getParent() != null) { reference.setParent(getParent().clone()); } return reference; } 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); }
EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { @Override public EntityReference clone() { EntityReference reference; try { reference = (EntityReference) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException("Failed to clone object", e); } reference.setName(getName()); reference.setType(getType()); if (getParent() != null) { reference.setParent(getParent().clone()); } return reference; } 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);  }