Update MutableTreeNode methods
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / tree / spi / MutableTreeNode.java
index c613d1d7893ee0320c6de1f2fb70cdca0b42faf3..9a95f3f6ceb618ddd045e483bd28824b7a062453 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.data.api.schema.tree.spi;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNode;
@@ -16,7 +17,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNode;
  * A mutable tree node. This is a transient view materialized from a pre-existing node. Modifications are isolated. Once
  * this object is {@link #seal()}ed, any interactions with it will result in undefined behavior.
  */
-// FIXME: 5.0.0: Use @NonNullByDefault
 public interface MutableTreeNode extends StoreTreeNode<TreeNode> {
     /**
      * Set the data component of the node.
@@ -36,22 +36,24 @@ public interface MutableTreeNode extends StoreTreeNode<TreeNode> {
     void setSubtreeVersion(Version subtreeVersion);
 
     /**
-     * Add a new child node. This acts as add-or-replace operation, e.g. it
-     * succeeds even if a conflicting child is already present.
+     * Add a new child node. This acts as add-or-replace operation, e.g. it succeeds even if a conflicting child is
+     * already present.
      *
      * @param child New child node.
+     * @return Replaced child, or null if there was no previous child
      * @throws NullPointerException if {@code child} is null
      */
-    void addChild(TreeNode child);
+    @Nullable TreeNode putChild(TreeNode child);
 
     /**
-     * Remove a child node. This acts as delete-or-nothing operation, e.g. it
-     * succeeds even if the corresponding child is not present.
+     * Remove a child node. This acts as delete-or-nothing operation, e.g. it succeeds even if the corresponding child
+     * is not present.
      *
      * @param id Child identifier.
+     * @return Removed child, or null if there was no matching child
      * @throws NullPointerException if {@code id} is null
      */
-    void removeChild(PathArgument id);
+    @Nullable TreeNode removeChild(PathArgument id);
 
     /**
      * Finish node modification and return a read-only view of this node. After