X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fyang-prototype%2Fyang%2Fyang-model-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fyang%2Fmodel%2Futil%2FDataNodeIterator.java;h=df111acf0854603d453f1c1bd6cefb40a449d48c;hb=9ceed566491d172e02220b04ec6869867f2f2473;hp=ded4a75179113327683a084bf15425b7b3f91d8d;hpb=f9de1cd89c17888a2bd02486d5f7519f0b391bba;p=controller.git diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/DataNodeIterator.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/DataNodeIterator.java index ded4a75179..df111acf08 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/DataNodeIterator.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/DataNodeIterator.java @@ -15,26 +15,28 @@ import org.opendaylight.controller.yang.model.api.ListSchemaNode; public class DataNodeIterator implements Iterator { private final DataNodeContainer container; - private final List allLists; - private final List allContainers; - private final List allLeafs; - private final List allLeafLists; - private final List allChilds; + private List allLists; + private List allContainers; + private List allLeafs; + private List allLeafLists; + private List allChilds; public DataNodeIterator(final DataNodeContainer container) { if (container == null) { - throw new IllegalArgumentException("Data Node Container MUST be specified!"); + throw new IllegalArgumentException("Data Node Container MUST be specified and cannot be NULL!"); } + init(); + this.container = container; + traverse(this.container); + } + + private void init() { this.allContainers = new ArrayList(); this.allLists = new ArrayList(); this.allLeafs = new ArrayList(); this.allLeafLists = new ArrayList(); this.allChilds = new ArrayList(); - - this.container = container; - - traverse(this.container); } public List allContainers() { @@ -54,13 +56,16 @@ public class DataNodeIterator implements Iterator { } private void traverse(final DataNodeContainer dataNode) { - if (!containChildDataNodeContainer(dataNode)) { + if (dataNode == null) { return; } - + final Set childs = dataNode.getChildNodes(); if (childs != null) { for (DataSchemaNode childNode : childs) { + if (childNode.isAugmenting()) { + continue; + } allChilds.add(childNode); if (childNode instanceof ContainerSchemaNode) { final ContainerSchemaNode container = (ContainerSchemaNode) childNode; @@ -78,33 +83,9 @@ public class DataNodeIterator implements Iterator { allLeafLists.add(leafList); } } + return; } } - - /** - * Returns true if and only if the child node contain at least - * one child container schema node or child list schema node, otherwise will - * always returns false - * - * @param container - * @return true if and only if the child node contain at least - * one child container schema node or child list schema node, - * otherwise will always returns false - */ - private boolean containChildDataNodeContainer( - final DataNodeContainer container) { - if (container != null) { - final Set childs = container.getChildNodes(); - if ((childs != null) && (childs.size() > 0)) { - for (final DataSchemaNode childNode : childs) { - if (childNode instanceof DataNodeContainer) { - return true; - } - } - } - } - return false; - } @Override public boolean hasNext() {