@Test public void testExtractReference() { EntityReference reference1 = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI))); Assert.assertEquals("wiki", reference1.extractReference(EntityType.WIKI).getName()); Assert.assertEquals("space", reference1.extractReference(EntityType.SPACE).getName()); Assert.assertEquals("page", reference1.extractReference(EntityType.DOCUMENT).getName()); Assert.assertNull(reference1.extractReference(EntityType.ATTACHMENT)); }
public EntityReference extractReference(EntityType type) { EntityReference reference = this; while (reference != null && reference.getType() != type) { reference = reference.getParent(); } return reference; }
EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { public EntityReference extractReference(EntityType type) { EntityReference reference = this; while (reference != null && reference.getType() != type) { reference = reference.getParent(); } return reference; } }
EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { public EntityReference extractReference(EntityType type) { EntityReference reference = this; while (reference != null && reference.getType() != type) { reference = reference.getParent(); } return reference; } EntityReference(String name, EntityType type);  EntityReference(String name, EntityType type, EntityReference parent); }
EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { public EntityReference extractReference(EntityType type) { EntityReference reference = this; while (reference != null && reference.getType() != type) { reference = reference.getParent(); } 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> { public EntityReference extractReference(EntityType type) { EntityReference reference = this; while (reference != null && reference.getType() != type) { reference = reference.getParent(); } 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);  }