Add a bit of documentation in AbstractReadyIterator 41/33041/1
authorRobert Varga <robert.varga@pantheon.sk>
Tue, 19 Jan 2016 21:21:31 +0000 (22:21 +0100)
committerRobert Varga <robert.varga@pantheon.sk>
Tue, 19 Jan 2016 21:24:30 +0000 (22:24 +0100)
Some of the comments have been lost. This class implements a depth-first
tree iterator, which does not use stack for keeping state, hence its
code flow should be better commented.

Change-Id: I604b0cef6f402c0e10403a7c29d272939ba2e8bd
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractReadyIterator.java

index 66a1cfe12649b8523717f1c23ca7fed3477988e1..ccb49c8a88eca67ed868f3d99bfc17c9f62764bb 100644 (file)
@@ -31,7 +31,8 @@ abstract class AbstractReadyIterator {
 
     final AbstractReadyIterator process(final Version version) {
         // Walk all child nodes and remove any children which have not
-        // been modified. If a child
+        // been modified. If a child has children, we need to iterate
+        // through it via re-entering this method on the child iterator.
         while (children.hasNext()) {
             final ModifiedNode child = children.next();
             final Optional<ModificationApplyOperation> childOperation = op.getChild(child.getIdentifier());
@@ -41,7 +42,7 @@ abstract class AbstractReadyIterator {
             final ModificationApplyOperation childOp = childOperation.get();
 
             if (grandChildren.isEmpty()) {
-
+                // The child is empty, seal it
                 child.seal(childOp, version);
                 if (child.getOperation() == LogicalOperation.NONE) {
                     children.remove();
@@ -51,12 +52,15 @@ abstract class AbstractReadyIterator {
             }
         }
 
+        // We are done with this node, seal it.
         node.seal(op, version);
 
         // Remove from parent if we have one and this is a no-op
         if (node.getOperation() == LogicalOperation.NONE) {
             removeFromParent();
         }
+
+        // Sub-iteration complete, return back to parent
         return getParent();
     }