Fix mandatory statement checking 14/49814/3
authorRobert Varga <rovarga@cisco.com>
Mon, 26 Dec 2016 16:34:10 +0000 (17:34 +0100)
committerRobert Varga <rovarga@cisco.com>
Wed, 4 Jan 2017 12:47:27 +0000 (13:47 +0100)
This fixes a mismatch between the comment and what the method
actually does. For some reason we ended up iterating over the same
collection twice.

Furthermore use .forEach() with a self-referencing lambda instead
of Iterables.concat(), as that can be optimized by the implementation.

Change-Id: I6f74794fd58576b9ce34b6f27217b5e81bef4457
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/AugmentStatementImpl.java

index 47e59579de98ea69e5b5a9b7430b96c3cf7ec4a9..b570d68908fc8149754195e86c9e0969d905a008 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 import com.google.common.base.Verify;
 import com.google.common.collect.ImmutableList.Builder;
 import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -272,10 +271,8 @@ public class AugmentStatementImpl extends AbstractDeclaredStatement<SchemaNodeId
                  * b) added to augment body also via uses of a grouping and
                  * such sub-statements are stored in effective sub-statements collection.
                  */
-                for (final StatementContextBase<?, ?, ?> sourceSubStatement : Iterables.concat(
-                        sourceCtx.declaredSubstatements(), sourceCtx.declaredSubstatements())) {
-                    checkForMandatoryNodes(sourceSubStatement);
-                }
+                sourceCtx.declaredSubstatements().forEach(Definition::checkForMandatoryNodes);
+                sourceCtx.effectiveSubstatements().forEach(Definition::checkForMandatoryNodes);
             }
 
             InferenceException.throwIf(StmtContextUtils.isMandatoryNode(sourceCtx),