示例#1
0
  public void update(final Office newParent) {

    if (this.parent == null) {
      throw new RootOfficeParentCannotBeUpdated();
    }

    if (this.identifiedBy(newParent.getId())) {
      throw new CannotUpdateOfficeWithParentOfficeSameAsSelf(this.getId(), newParent.getId());
    }

    this.parent = newParent;
    generateHierarchy();
  }
示例#2
0
  private boolean hasAnOfficeInHierarchyWithId(final Long officeId) {

    boolean match = false;

    if (identifiedBy(officeId)) {
      match = true;
    }

    if (!match) {
      for (final Office child : this.children) {
        final boolean result = child.hasAnOfficeInHierarchyWithId(officeId);

        if (result) {
          match = result;
          break;
        }
      }
    }

    return match;
  }