Next round of yang-parser-impl checkstyle fixes
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / AugmentStatementImpl.java
index 9a334b2b5a6f7537c3e295e25933895b99f29889..9bceed925ad8c6782df94fa43fcf4eb39a8fafd3 100644 (file)
@@ -8,11 +8,9 @@
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
 import com.google.common.base.Verify;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.List;
 import java.util.Objects;
 import java.util.Set;
 import java.util.regex.Pattern;
@@ -74,8 +72,8 @@ public class AugmentStatementImpl extends AbstractDeclaredStatement<SchemaNodeId
         super(context);
     }
 
-    public static class Definition extends
-            AbstractStatementSupport<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> {
+    public static class Definition extends AbstractStatementSupport<SchemaNodeIdentifier, AugmentStatement,
+            EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> {
 
         public Definition() {
             super(YangStmtMapping.AUGMENT);
@@ -99,13 +97,14 @@ public class AugmentStatementImpl extends AbstractDeclaredStatement<SchemaNodeId
 
         @Override
         public EffectiveStatement<SchemaNodeIdentifier, AugmentStatement> createEffective(
-                final StmtContext<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> ctx) {
+                final StmtContext<SchemaNodeIdentifier, AugmentStatement,
+                EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> ctx) {
             return new AugmentEffectiveStatementImpl(ctx);
         }
 
         @Override
-        public void onFullDefinitionDeclared(
-                final Mutable<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> augmentNode) {
+        public void onFullDefinitionDeclared(final Mutable<SchemaNodeIdentifier, AugmentStatement,
+                EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> augmentNode) {
             if (!augmentNode.isSupportedByFeatures()) {
                 return;
             }
@@ -118,12 +117,14 @@ public class AugmentStatementImpl extends AbstractDeclaredStatement<SchemaNodeId
 
             final ModelActionBuilder augmentAction = augmentNode.newInferenceAction(
                 ModelProcessingPhase.EFFECTIVE_MODEL);
-            final ModelActionBuilder.Prerequisite<StmtContext<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>>> sourceCtxPrereq =
+            final Prerequisite<StmtContext<SchemaNodeIdentifier, AugmentStatement,
+                EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>>> sourceCtxPrereq =
                     augmentAction.requiresCtx(augmentNode, ModelProcessingPhase.EFFECTIVE_MODEL);
             final Prerequisite<Mutable<?, ?, EffectiveStatement<?, ?>>> target =
-                    augmentAction.mutatesEffectiveCtx(getSearchRoot(augmentNode), SchemaNodeIdentifierBuildNamespace.class, augmentNode.getStatementArgument());
-            augmentAction.apply(new ModelActionBuilder.InferenceAction() {
+                    augmentAction.mutatesEffectiveCtx(getSearchRoot(augmentNode),
+                        SchemaNodeIdentifierBuildNamespace.class, augmentNode.getStatementArgument());
 
+            augmentAction.apply(new ModelActionBuilder.InferenceAction() {
                 @Override
                 public void apply(final ModelActionBuilder.InferenceContext ctx) {
                     final StatementContextBase<?, ?, ?> augmentTargetCtx =
@@ -266,11 +267,7 @@ public class AugmentStatementImpl extends AbstractDeclaredStatement<SchemaNodeId
                 checkForMandatoryNodes(sourceCtx);
             }
 
-            final List<Mutable<?, ?, ?>> targetSubStatements = ImmutableList.<Mutable<?, ?, ?>>builder()
-                    .addAll(targetCtx.mutableDeclaredSubstatements()).addAll(targetCtx.mutableEffectiveSubstatements())
-                    .build();
-
-            for (final Mutable<?, ?, ?> subStatement : targetSubStatements) {
+            for (final StmtContext<?, ?, ?> subStatement : targetCtx.allSubstatements()) {
                 final boolean sourceIsDataNode = DataDefinitionStatement.class.isAssignableFrom(sourceCtx
                         .getPublicDefinition().getDeclaredRepresentationClass());
                 final boolean targetIsDataNode = DataDefinitionStatement.class.isAssignableFrom(subStatement
@@ -293,8 +290,7 @@ 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.
                  */
-                sourceCtx.declaredSubstatements().forEach(Definition::checkForMandatoryNodes);
-                sourceCtx.effectiveSubstatements().forEach(Definition::checkForMandatoryNodes);
+                sourceCtx.allSubstatementsStream().forEach(Definition::checkForMandatoryNodes);
             }
 
             InferenceException.throwIf(StmtContextUtils.isMandatoryNode(sourceCtx),
@@ -350,8 +346,8 @@ public class AugmentStatementImpl extends AbstractDeclaredStatement<SchemaNodeId
             return false;
         }
 
-        private static final Set<YangStmtMapping> NOCOPY_DEF_SET = ImmutableSet.of(YangStmtMapping.USES, YangStmtMapping.WHEN,
-                YangStmtMapping.DESCRIPTION, YangStmtMapping.REFERENCE, YangStmtMapping.STATUS);
+        private static final Set<YangStmtMapping> NOCOPY_DEF_SET = ImmutableSet.of(YangStmtMapping.USES,
+            YangStmtMapping.WHEN, YangStmtMapping.DESCRIPTION, YangStmtMapping.REFERENCE, YangStmtMapping.STATUS);
 
         public static boolean needToCopyByAugment(final StmtContext<?, ?, ?> stmtContext) {
             return !NOCOPY_DEF_SET.contains(stmtContext.getPublicDefinition());