예제 #1
0
  // TODO(jannewger): this method doesn't seem to be correct: the list of references isn't cloned
  // so the clone as well as the original COperandTreeNode refer to the same list of references.
  // Also, it is a mutable field which means that changes in the original instance are reflected to
  // the clone, and vice versa. The same holds true for TypeSubstitutions: we should discuss whether
  // this is desired behavior. It clearly breaks the strict "clone contract".
  public COperandTreeNode cloneNode() {
    final COperandTreeNode clonedNode =
        new COperandTreeNode(
            id,
            expressionType,
            expressionValue,
            replacement == null ? null : replacement.cloneReplacement(),
            references,
            provider);

    for (final COperandTreeNode child : children) {
      COperandTreeNode.link(clonedNode, child.cloneNode());
    }

    return clonedNode;
  }
예제 #2
0
 /**
  * Links two operand tree nodes.
  *
  * @param parent The parent node.
  * @param child The child node that is added to the parent.
  */
 public static void link(final COperandTreeNode parent, final COperandTreeNode child) {
   Preconditions.checkNotNull(child, "IE00218: Child argument can not be null");
   Preconditions.checkNotNull(parent, "IE00217: Parent argument can not be null");
   parent.children.add(child);
   child.parent = parent;
 }