@Override
  void replaceChild(
      @SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild) {
    // Replace child
    if (this._quad_ == oldChild) {
      setQuad((TQuad) newChild);
      return;
    }

    for (ListIterator<TId> i = this._path_.listIterator(); i.hasNext(); ) {
      if (i.next() == oldChild) {
        if (newChild != null) {
          i.set((TId) newChild);
          newChild.parent(this);
          oldChild.parent(null);
          return;
        }

        i.remove();
        oldChild.parent(null);
        return;
      }
    }

    if (this._id_ == oldChild) {
      setId((TId) newChild);
      return;
    }

    throw new RuntimeException("Not a child.");
  }
Beispiel #2
0
  @Override
  void replaceChild(
      @SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild) {
    // Replace child
    if (this._className_ == oldChild) {
      setClassName((TId) newChild);
      return;
    }

    if (this._super_ == oldChild) {
      setSuper((TId) newChild);
      return;
    }

    for (ListIterator<PVarDecl> i = this._varDecl_.listIterator(); i.hasNext(); ) {
      if (i.next() == oldChild) {
        if (newChild != null) {
          i.set((PVarDecl) newChild);
          newChild.parent(this);
          oldChild.parent(null);
          return;
        }

        i.remove();
        oldChild.parent(null);
        return;
      }
    }

    for (ListIterator<PMethodDecl> i = this._methodDecl_.listIterator(); i.hasNext(); ) {
      if (i.next() == oldChild) {
        if (newChild != null) {
          i.set((PMethodDecl) newChild);
          newChild.parent(this);
          oldChild.parent(null);
          return;
        }

        i.remove();
        oldChild.parent(null);
        return;
      }
    }

    throw new RuntimeException("Not a child.");
  }