Пример #1
0
  @Override
  public IEntity getRootEntity() {
    IEntity rootEntity = this;

    while (rootEntity.hasParent()) {
      rootEntity = rootEntity.getParent();
    }

    return rootEntity;
  }
Пример #2
0
 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
             + "'!");
   }
 }