Merge "Modified RpcResultBuilder classes to be Serializable"
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / DataNodeIterator.java
index ed1db9a31505fc3ca961704e002862268975ca9f..025c11c1e26b3fd53d1f7b99b28be84fcb65f59c 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
@@ -24,6 +25,15 @@ import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
+/**
+ * DataNodeIterator is iterator, which walks down whole YANG DataNodeContainer
+ * and walks all instances of {@link DataSchemaNode} present in subtree.
+ *
+ * Iterator instance is eagerly created, walking happens on initialization.
+ *
+ * Iteration is not ordered.
+ *
+ */
 public class DataNodeIterator implements Iterator<DataSchemaNode> {
 
     private final DataNodeContainer container;
@@ -50,22 +60,47 @@ public class DataNodeIterator implements Iterator<DataSchemaNode> {
         traverse(this.container);
     }
 
+    /**
+     * Returns list all containers present in subtree.
+     *
+     * @return Returns list all containers present in subtree.
+     */
     public List<ContainerSchemaNode> allContainers() {
         return allContainers;
     }
 
+    /**
+     * Returns list all lists present in subtree.
+     *
+     * @return Returns list all containers present in subtree.
+     */
     public List<ListSchemaNode> allLists() {
         return allLists;
     }
 
+    /**
+     * Returns list all choices present in subtree.
+     *
+     * @return Returns list all containers present in subtree.
+     */
     public List<ChoiceNode> allChoices() {
         return allChoices;
     }
 
+    /**
+     * Returns list all groupings present in subtree.
+     *
+     * @return Returns list all containers present in subtree.
+     */
     public List<GroupingDefinition> allGroupings() {
         return allGroupings;
     }
 
+    /**
+     * Returns list all typedefs present in subtree.
+     *
+     * @return Returns list all containers present in subtree.
+     */
     public List<TypeDefinition<?>> allTypedefs() {
         return allTypedefs;
     }
@@ -75,7 +110,7 @@ public class DataNodeIterator implements Iterator<DataSchemaNode> {
             return;
         }
 
-        final Set<DataSchemaNode> childNodes = dataNode.getChildNodes();
+        final Iterable<DataSchemaNode> childNodes = dataNode.getChildNodes();
         if (childNodes != null) {
             for (DataSchemaNode childNode : childNodes) {
                 if (childNode.isAugmenting()) {
@@ -109,7 +144,7 @@ public class DataNodeIterator implements Iterator<DataSchemaNode> {
 
     }
 
-    private void traverseModule(DataNodeContainer dataNode) {
+    private void traverseModule(final DataNodeContainer dataNode) {
         final Module module;
         if (dataNode instanceof Module) {
             module = (Module) dataNode;
@@ -136,7 +171,7 @@ public class DataNodeIterator implements Iterator<DataSchemaNode> {
         }
     }
 
-    private void traverseGroupings(DataNodeContainer dataNode) {
+    private void traverseGroupings(final DataNodeContainer dataNode) {
         final Set<GroupingDefinition> groupings = dataNode.getGroupings();
         if (groupings != null) {
             for (GroupingDefinition grouping : groupings) {
@@ -149,7 +184,7 @@ public class DataNodeIterator implements Iterator<DataSchemaNode> {
     @Override
     public boolean hasNext() {
         if (container.getChildNodes() != null) {
-            final Set<DataSchemaNode> childNodes = container.getChildNodes();
+            final Collection<DataSchemaNode> childNodes = container.getChildNodes();
 
             if ((childNodes != null) && !childNodes.isEmpty()) {
                 return childNodes.iterator().hasNext();