@Override public IEntity getRootEntity() { IEntity rootEntity = this; while (rootEntity.hasParent()) { rootEntity = rootEntity.getParent(); } return rootEntity; }
private void assertEntityHasNoParent(final IEntity pEntity) throws IllegalStateException { if (pEntity.hasParent()) { final String entityClassName = pEntity.getClass().getSimpleName(); final String currentParentClassName = pEntity.getParent().getClass().getSimpleName(); final String newParentClassName = this.getClass().getSimpleName(); throw new IllegalStateException( "pEntity '" + entityClassName + "' already has a parent: '" + currentParentClassName + "'. New parent: '" + newParentClassName + "'!"); } }