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;
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;
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;
}
return;
}
- final Set<DataSchemaNode> childNodes = dataNode.getChildNodes();
+ final Iterable<DataSchemaNode> childNodes = dataNode.getChildNodes();
if (childNodes != null) {
for (DataSchemaNode childNode : childNodes) {
if (childNode.isAugmenting()) {
}
- private void traverseModule(DataNodeContainer dataNode) {
+ private void traverseModule(final DataNodeContainer dataNode) {
final Module module;
if (dataNode instanceof Module) {
module = (Module) dataNode;
}
}
- private void traverseGroupings(DataNodeContainer dataNode) {
+ private void traverseGroupings(final DataNodeContainer dataNode) {
final Set<GroupingDefinition> groupings = dataNode.getGroupings();
if (groupings != null) {
for (GroupingDefinition grouping : groupings) {
@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();