Bug 1677 - Parser: ListSchemaNodeBuilder keys needs to be a LinkedHashSet 36/10836/5
authorLadislav Borak <lborak@cisco.com>
Fri, 5 Sep 2014 06:14:55 +0000 (08:14 +0200)
committerLadislav Borak <lborak@cisco.com>
Mon, 10 Nov 2014 13:59:33 +0000 (14:59 +0100)
- changed type of kyes in ListSchemaNodeBuilder

Change-Id: I838d51b76f70f6446169f72407db8da43fb5ee03
Signed-off-by: Ladislav Borak <lborak@cisco.com>
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ListSchemaNodeBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/ParserListenerUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangParserListenerImpl.java

index 4e3649c44fc192d76e2c754b531c33beb611a17b..d99f774a9aa72f4668aefcd833f0a6cc0a45022a 100644 (file)
@@ -36,7 +36,7 @@ public final class ListSchemaNodeBuilder extends AbstractDocumentedDataNodeConta
         DataSchemaNodeBuilder, AugmentationTargetBuilder {
     private ListSchemaNodeImpl instance;
     private boolean userOrdered;
-    private List<String> keys;
+    private Set<String> keys;
     private List<QName> keyDefinition;
     // SchemaNode args
     private SchemaPath schemaPath;
@@ -155,11 +155,11 @@ public final class ListSchemaNodeBuilder extends AbstractDocumentedDataNodeConta
         return augmentationBuilders;
     }
 
-    public List<String> getKeys() {
+    public Set<String> getKeys() {
         return keys;
     }
 
-    public void setKeys(final List<String> keys) {
+    public void setKeys(final Set<String> keys) {
         this.keys = keys;
     }
 
index 493db98790228763756264aef69cc54f752c3dc2..eaece86cadde4c6b930228fd38c2d95cb55d85ff 100644 (file)
@@ -12,13 +12,14 @@ import static com.google.common.base.Preconditions.checkState;
 import com.google.common.base.CharMatcher;
 import com.google.common.base.Optional;
 import com.google.common.base.Splitter;
-import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 import org.antlr.v4.runtime.ParserRuleContext;
@@ -305,15 +306,15 @@ public final class ParserListenerUtils {
     }
 
     /**
-     * Create java.util.List of key node names.
+     * Create java.util.LinkedHashSet of key node names.
      *
      * @param ctx
      *            Key_stmtContext context
-     * @return YANG list key as java.util.List of key node names
+     * @return YANG list key as java.util.LinkedHashSet of key node names
      */
-    public static List<String> createListKey(final Key_stmtContext ctx) {
-        String keyDefinition = stringFromNode(ctx);
-        return Lists.newArrayList(KEYDEF_SPLITTER.split(keyDefinition));
+    public static Set<String> createListKey(final Key_stmtContext ctx) {
+        final String keyDefinition = stringFromNode(ctx);
+        return Sets.<String>newLinkedHashSet(KEYDEF_SPLITTER.split(keyDefinition));
     }
 
     /**
index fdaaf33d8865c085dec2ee0c34526962d7f67f14..e5127b3142f1082f47f4789ffaa7acae875bc4b4 100644 (file)
@@ -34,6 +34,7 @@ import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.TreeMap;
 import org.antlr.v4.runtime.tree.ParseTree;
 import org.antlr.v4.runtime.tree.ParseTreeWalker;
@@ -216,7 +217,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     public void enterBelongs_to_stmt(final YangParser.Belongs_to_stmtContext ctx) {
         final String belongsTo = stringFromNode(ctx);
         TreeMap<Date, URI> context = namespaceContext.get(belongsTo);
-        Map.Entry<Date, URI> entry = context.firstEntry();
+        final Map.Entry<Date, URI> entry = context.firstEntry();
         // TODO
         // Submodule will contain namespace and revision from module to which it
         // belongs. If there are multiple modules with same name and different
@@ -272,7 +273,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
     public void enterMeta_stmts(final YangParser.Meta_stmtsContext ctx) {
         enterLog("meta_stmt", "", ctx.getStart().getLine());
         for (int i = 0; i < ctx.getChildCount(); i++) {
-            ParseTree child = ctx.getChild(i);
+            final ParseTree child = ctx.getChild(i);
             if (child instanceof Organization_stmtContext) {
                 final String organization = stringFromNode(child);
                 moduleBuilder.setOrganization(organization);
@@ -373,9 +374,9 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
 
         Date includeRevision = null;
         for (int i = 0; i < ctx.getChildCount(); i++) {
-            ParseTree treeNode = ctx.getChild(i);
+            final ParseTree treeNode = ctx.getChild(i);
             if (treeNode instanceof Revision_date_stmtContext) {
-                String importRevisionStr = stringFromNode(treeNode);
+                final String importRevisionStr = stringFromNode(treeNode);
                 try {
                     includeRevision = SIMPLE_DATE_FORMAT.parse(importRevisionStr);
                 } catch (ParseException e) {
@@ -397,8 +398,8 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         enterLog(AUGMENT_STR, augmentPath, line);
         stack.push();
 
-        SchemaPath targetPath = parseXPathString(augmentPath, line);
-        AugmentationSchemaBuilder builder = moduleBuilder.addAugment(line, augmentPath, targetPath, augmentOrder++);
+        final SchemaPath targetPath = parseXPathString(augmentPath, line);
+        final AugmentationSchemaBuilder builder = moduleBuilder.addAugment(line, augmentPath, targetPath, augmentOrder++);
 
         for (int i = 0; i < ctx.getChildCount(); i++) {
             ParseTree child = ctx.getChild(i);
@@ -428,16 +429,16 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final int line = ctx.getStart().getLine();
         final String extName = stringFromNode(ctx);
         enterLog("extension", extName, line);
-        QName qname = QName.create(moduleQName, extName);
-        SchemaPath path = stack.addNodeToPath(qname);
+        final QName qname = QName.create(moduleQName, extName);
+        final SchemaPath path = stack.addNodeToPath(qname);
 
-        ExtensionBuilder builder = moduleBuilder.addExtension(qname, line, path);
+        final ExtensionBuilder builder = moduleBuilder.addExtension(qname, line, path);
         parseSchemaNodeArgs(ctx, builder);
 
         String argument = null;
         boolean yin = false;
         for (int i = 0; i < ctx.getChildCount(); i++) {
-            ParseTree child = ctx.getChild(i);
+            final ParseTree child = ctx.getChild(i);
             if (child instanceof Argument_stmtContext) {
                 argument = stringFromNode(child);
                 yin = parseYinValue((Argument_stmtContext) child);
@@ -461,10 +462,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final int line = ctx.getStart().getLine();
         final String typedefName = stringFromNode(ctx);
         enterLog("typedef", typedefName, line);
-        QName typedefQName = QName.create(moduleQName, typedefName);
-        SchemaPath path = stack.addNodeToPath(typedefQName);
+        final QName typedefQName = QName.create(moduleQName, typedefName);
+        final SchemaPath path = stack.addNodeToPath(typedefQName);
 
-        TypeDefinitionBuilder builder = moduleBuilder.addTypedef(line, typedefQName, path);
+        final TypeDefinitionBuilder builder = moduleBuilder.addTypedef(line, typedefQName, path);
         parseSchemaNodeArgs(ctx, builder);
         builder.setUnits(parseUnits(ctx));
         builder.setDefaultValue(parseDefault(ctx));
@@ -510,14 +511,14 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                 case "union":
                     qname = BaseTypes.UNION_QNAME;
                     stack.addNodeToPath(qname);
-                    UnionTypeBuilder unionBuilder = moduleBuilder.addUnionType(line, moduleQName.getModule());
-                    Builder parent = moduleBuilder.getActualNode();
+                    final UnionTypeBuilder unionBuilder = moduleBuilder.addUnionType(line, moduleQName.getModule());
+                    final Builder parent = moduleBuilder.getActualNode();
                     unionBuilder.setParent(parent);
                     moduleBuilder.enterNode(unionBuilder);
                     break;
                 case "identityref":
                     qname = BaseTypes.IDENTITYREF_QNAME;
-                    SchemaPath path = stack.addNodeToPath(qname);
+                    final SchemaPath path = stack.addNodeToPath(qname);
                     moduleBuilder.addIdentityrefType(line, path, getIdentityrefBase(typeBody));
                     break;
                 default:
@@ -528,7 +529,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                 }
             }
         } else {
-            TypeAwareBuilder parent = (TypeAwareBuilder) moduleBuilder.getActualNode();
+            final TypeAwareBuilder parent = (TypeAwareBuilder) moduleBuilder.getActualNode();
             if (typeBody == null) {
                 parent.setTypeQName(typeQName);
                 moduleBuilder.markActualNodeDirty();
@@ -565,7 +566,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
             if (prefix.equals(moduleBuilder.getPrefix())) {
                 qname = QName.create(moduleQName, name);
             } else {
-                ModuleImport imp = moduleBuilder.getImport(prefix);
+                final ModuleImport imp = moduleBuilder.getImport(prefix);
                 if (imp == null) {
                     LOG.debug("Error in module {} at line {}: No import found with prefix {}", moduleName, line, prefix);
                     throw new YangParseException(moduleName, line, "Error in module " + moduleName
@@ -609,10 +610,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final int line = ctx.getStart().getLine();
         final String groupName = stringFromNode(ctx);
         enterLog("grouping", groupName, line);
-        QName groupQName = QName.create(moduleQName, groupName);
-        SchemaPath path = stack.addNodeToPath(groupQName);
+        final QName groupQName = QName.create(moduleQName, groupName);
+        final SchemaPath path = stack.addNodeToPath(groupQName);
 
-        GroupingBuilder builder = moduleBuilder.addGrouping(ctx.getStart().getLine(), groupQName, path);
+        final GroupingBuilder builder = moduleBuilder.addGrouping(ctx.getStart().getLine(), groupQName, path);
         parseSchemaNodeArgs(ctx, builder);
 
         moduleBuilder.enterNode(builder);
@@ -630,10 +631,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String containerName = stringFromNode(ctx);
         enterLog("container", containerName, line);
 
-        QName containerQName = QName.create(moduleQName, containerName);
-        SchemaPath path = stack.addNodeToPath(containerQName);
+        final QName containerQName = QName.create(moduleQName, containerName);
+        final SchemaPath path = stack.addNodeToPath(containerQName);
 
-        ContainerSchemaNodeBuilder builder = moduleBuilder.addContainerNode(line, containerQName, path);
+        final ContainerSchemaNodeBuilder builder = moduleBuilder.addContainerNode(line, containerQName, path);
         parseSchemaNodeArgs(ctx, builder);
         parseConstraints(ctx, builder.getConstraints());
         builder.setConfiguration(getConfig(ctx, builder, moduleName, line));
@@ -661,10 +662,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String leafName = stringFromNode(ctx);
         enterLog("leaf", leafName, line);
 
-        QName leafQName = QName.create(moduleQName, leafName);
-        SchemaPath path = stack.addNodeToPath(leafQName);
+        final QName leafQName = QName.create(moduleQName, leafName);
+        final SchemaPath path = stack.addNodeToPath(leafQName);
 
-        LeafSchemaNodeBuilder builder = moduleBuilder.addLeafNode(line, leafQName, path);
+        final LeafSchemaNodeBuilder builder = moduleBuilder.addLeafNode(line, leafQName, path);
         parseSchemaNodeArgs(ctx, builder);
         parseConstraints(ctx, builder.getConstraints());
         builder.setConfiguration(getConfig(ctx, builder, moduleName, line));
@@ -672,7 +673,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         String defaultStr = null;
         String unitsStr = null;
         for (int i = 0; i < ctx.getChildCount(); i++) {
-            ParseTree child = ctx.getChild(i);
+            final ParseTree child = ctx.getChild(i);
             if (child instanceof Default_stmtContext) {
                 defaultStr = stringFromNode(child);
             } else if (child instanceof Units_stmtContext) {
@@ -698,7 +699,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final SchemaPath groupingPath = parseXPathString(groupingPathStr, line);
         enterLog("uses", groupingPathStr, line);
 
-        UsesNodeBuilder builder = moduleBuilder.addUsesNode(line, groupingPath);
+        final UsesNodeBuilder builder = moduleBuilder.addUsesNode(line, groupingPath);
 
         moduleBuilder.enterNode(builder);
     }
@@ -716,11 +717,11 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         enterLog(AUGMENT_STR, augmentPath, line);
         stack.push();
 
-        SchemaPath targetPath = parseXPathString(augmentPath, line);
-        AugmentationSchemaBuilder builder = moduleBuilder.addAugment(line, augmentPath, targetPath, augmentOrder++);
+        final SchemaPath targetPath = parseXPathString(augmentPath, line);
+        final AugmentationSchemaBuilder builder = moduleBuilder.addAugment(line, augmentPath, targetPath, augmentOrder++);
 
         for (int i = 0; i < ctx.getChildCount(); i++) {
-            ParseTree child = ctx.getChild(i);
+            final ParseTree child = ctx.getChild(i);
             if (child instanceof Description_stmtContext) {
                 builder.setDescription(stringFromNode(child));
             } else if (child instanceof Reference_stmtContext) {
@@ -747,7 +748,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String refineString = stringFromNode(ctx);
         enterLog("refine", refineString, ctx.getStart().getLine());
 
-        RefineHolderImpl refine = parseRefine(ctx, moduleName);
+        final RefineHolderImpl refine = parseRefine(ctx, moduleName);
         moduleBuilder.addRefine(refine);
         moduleBuilder.enterNode(refine);
     }
@@ -763,10 +764,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final int line = ctx.getStart().getLine();
         final String leafListName = stringFromNode(ctx);
         enterLog("leaf-list", leafListName, line);
-        QName leafListQName = QName.create(moduleQName, leafListName);
-        SchemaPath path = stack.addNodeToPath(leafListQName);
+        final QName leafListQName = QName.create(moduleQName, leafListName);
+        final SchemaPath path = stack.addNodeToPath(leafListQName);
 
-        LeafListSchemaNodeBuilder builder = moduleBuilder.addLeafListNode(line, leafListQName, path);
+        final LeafListSchemaNodeBuilder builder = moduleBuilder.addLeafListNode(line, leafListQName, path);
         moduleBuilder.enterNode(builder);
 
         parseSchemaNodeArgs(ctx, builder);
@@ -796,10 +797,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String listName = stringFromNode(ctx);
         enterLog("list", listName, line);
 
-        QName listQName = QName.create(moduleQName, listName);
-        SchemaPath path = stack.addNodeToPath(listQName);
+        final QName listQName = QName.create(moduleQName, listName);
+        final SchemaPath path = stack.addNodeToPath(listQName);
 
-        ListSchemaNodeBuilder builder = moduleBuilder.addListNode(line, listQName, path);
+        final ListSchemaNodeBuilder builder = moduleBuilder.addListNode(line, listQName, path);
         moduleBuilder.enterNode(builder);
 
         parseSchemaNodeArgs(ctx, builder);
@@ -807,13 +808,13 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         builder.setConfiguration(getConfig(ctx, builder, moduleName, line));
 
         for (int i = 0; i < ctx.getChildCount(); ++i) {
-            ParseTree childNode = ctx.getChild(i);
+            final ParseTree childNode = ctx.getChild(i);
             if (childNode instanceof Ordered_by_stmtContext) {
                 final Ordered_by_stmtContext orderedBy = (Ordered_by_stmtContext) childNode;
                 final boolean userOrdered = parseUserOrdered(orderedBy);
                 builder.setUserOrdered(userOrdered);
             } else if (childNode instanceof Key_stmtContext) {
-                List<String> key = createListKey((Key_stmtContext) childNode);
+                final Set<String> key = createListKey((Key_stmtContext) childNode);
                 builder.setKeys(key);
             }
         }
@@ -831,10 +832,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String anyXmlName = stringFromNode(ctx);
         enterLog("anyxml", anyXmlName, line);
 
-        QName anyXmlQName = QName.create(moduleQName, anyXmlName);
-        SchemaPath path = stack.addNodeToPath(anyXmlQName);
+        final QName anyXmlQName = QName.create(moduleQName, anyXmlName);
+        final SchemaPath path = stack.addNodeToPath(anyXmlQName);
 
-        AnyXmlBuilder builder = moduleBuilder.addAnyXml(line, anyXmlQName, path);
+        final AnyXmlBuilder builder = moduleBuilder.addAnyXml(line, anyXmlQName, path);
         moduleBuilder.enterNode(builder);
 
         parseSchemaNodeArgs(ctx, builder);
@@ -854,10 +855,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String choiceName = stringFromNode(ctx);
         enterLog("choice", choiceName, line);
 
-        QName choiceQName = QName.create(moduleQName, choiceName);
-        SchemaPath path = stack.addNodeToPath(choiceQName);
+        final QName choiceQName = QName.create(moduleQName, choiceName);
+        final SchemaPath path = stack.addNodeToPath(choiceQName);
 
-        ChoiceBuilder builder = moduleBuilder.addChoice(line, choiceQName, path);
+        final ChoiceBuilder builder = moduleBuilder.addChoice(line, choiceQName, path);
         moduleBuilder.enterNode(builder);
 
         parseSchemaNodeArgs(ctx, builder);
@@ -866,9 +867,9 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
 
         // set 'default' case
         for (int i = 0; i < ctx.getChildCount(); i++) {
-            ParseTree child = ctx.getChild(i);
+            final ParseTree child = ctx.getChild(i);
             if (child instanceof Default_stmtContext) {
-                String defaultCase = stringFromNode(child);
+                final String defaultCase = stringFromNode(child);
                 builder.setDefaultCase(defaultCase);
                 break;
             }
@@ -887,10 +888,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String caseName = stringFromNode(ctx);
         enterLog("case", caseName, line);
 
-        QName caseQName = QName.create(moduleQName, caseName);
-        SchemaPath path = stack.addNodeToPath(caseQName);
+        final QName caseQName = QName.create(moduleQName, caseName);
+        final SchemaPath path = stack.addNodeToPath(caseQName);
 
-        ChoiceCaseBuilder builder = moduleBuilder.addCase(line, caseQName, path);
+        final ChoiceCaseBuilder builder = moduleBuilder.addCase(line, caseQName, path);
         moduleBuilder.enterNode(builder);
 
         parseSchemaNodeArgs(ctx, builder);
@@ -909,10 +910,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String notificationName = stringFromNode(ctx);
         enterLog("notification", notificationName, line);
 
-        QName notificationQName = QName.create(moduleQName, notificationName);
-        SchemaPath path = stack.addNodeToPath(notificationQName);
+        final QName notificationQName = QName.create(moduleQName, notificationName);
+        final SchemaPath path = stack.addNodeToPath(notificationQName);
 
-        NotificationBuilder builder = moduleBuilder.addNotification(line, notificationQName, path);
+        final NotificationBuilder builder = moduleBuilder.addNotification(line, notificationQName, path);
         moduleBuilder.enterNode(builder);
 
         parseSchemaNodeArgs(ctx, builder);
@@ -951,13 +952,12 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String rpcName = stringFromNode(ctx);
         enterLog("rpc", rpcName, line);
 
-        QName rpcQName = QName.create(moduleQName, rpcName);
-        SchemaPath path = stack.addNodeToPath(rpcQName);
+        final QName rpcQName = QName.create(moduleQName, rpcName);
+        final SchemaPath path = stack.addNodeToPath(rpcQName);
 
-        RpcDefinitionBuilder rpcBuilder = moduleBuilder.addRpc(line, rpcQName, path);
+        final RpcDefinitionBuilder rpcBuilder = moduleBuilder.addRpc(line, rpcQName, path);
         moduleBuilder.enterNode(rpcBuilder);
 
-
         parseSchemaNodeArgs(ctx, rpcBuilder);
     }
 
@@ -973,10 +973,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String input = "input";
         enterLog(input, input, line);
 
-        QName rpcQName = QName.create(moduleQName, input);
-        SchemaPath path = stack.addNodeToPath(rpcQName);
+        final QName rpcQName = QName.create(moduleQName, input);
+        final SchemaPath path = stack.addNodeToPath(rpcQName);
 
-        ContainerSchemaNodeBuilder builder = moduleBuilder.addRpcInput(line, rpcQName, path);
+        final ContainerSchemaNodeBuilder builder = moduleBuilder.addRpcInput(line, rpcQName, path);
         moduleBuilder.enterNode(builder);
         builder.setConfiguration(true);
 
@@ -996,10 +996,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String output = "output";
         enterLog(output, output, line);
 
-        QName rpcQName = QName.create(moduleQName, output);
-        SchemaPath path = stack.addNodeToPath(rpcQName);
+        final QName rpcQName = QName.create(moduleQName, output);
+        final SchemaPath path = stack.addNodeToPath(rpcQName);
 
-        ContainerSchemaNodeBuilder builder = moduleBuilder.addRpcOutput(path, rpcQName, line);
+        final ContainerSchemaNodeBuilder builder = moduleBuilder.addRpcOutput(path, rpcQName, line);
         moduleBuilder.enterNode(builder);
         builder.setConfiguration(true);
 
@@ -1019,10 +1019,10 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         final String featureName = stringFromNode(ctx);
         enterLog("feature", featureName, line);
 
-        QName featureQName = QName.create(moduleQName, featureName);
-        SchemaPath path = stack.addNodeToPath(featureQName);
+        final QName featureQName = QName.create(moduleQName, featureName);
+        final SchemaPath path = stack.addNodeToPath(featureQName);
 
-        FeatureBuilder featureBuilder = moduleBuilder.addFeature(line, featureQName, path);
+        final FeatureBuilder featureBuilder = moduleBuilder.addFeature(line, featureQName, path);
         moduleBuilder.enterNode(featureBuilder);
 
         parseSchemaNodeArgs(ctx, featureBuilder);
@@ -1047,8 +1047,8 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         String reference = null;
         String deviate = null;
 
-        SchemaPath targetPath = parseXPathString(targetPathStr, line);
-        DeviationBuilder builder = moduleBuilder.addDeviation(line, targetPath);
+        final SchemaPath targetPath = parseXPathString(targetPathStr, line);
+        final DeviationBuilder builder = moduleBuilder.addDeviation(line, targetPath);
         moduleBuilder.enterNode(builder);
 
         for (int i = 0; i < ctx.getChildCount(); i++) {
@@ -1098,15 +1098,15 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         enterLog("identity", identityName, line);
 
         final QName identityQName = QName.create(moduleQName, identityName);
-        SchemaPath path = stack.addNodeToPath(identityQName);
+        final SchemaPath path = stack.addNodeToPath(identityQName);
 
-        IdentitySchemaNodeBuilder builder = moduleBuilder.addIdentity(identityQName, line, path);
+        final IdentitySchemaNodeBuilder builder = moduleBuilder.addIdentity(identityQName, line, path);
         moduleBuilder.enterNode(builder);
 
         parseSchemaNodeArgs(ctx, builder);
 
         for (int i = 0; i < ctx.getChildCount(); i++) {
-            ParseTree child = ctx.getChild(i);
+            final ParseTree child = ctx.getChild(i);
             if (child instanceof Base_stmtContext) {
                 String baseIdentityName = stringFromNode(child);
                 builder.setBaseIdentityName(baseIdentityName);
@@ -1145,7 +1145,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
         enterLog("unknown-node", nodeParameter, line);
 
         final String nodeTypeStr = ctx.getChild(0).getText();
-        QName nodeType = parseQName(nodeTypeStr, line);
+        final QName nodeType = parseQName(nodeTypeStr, line);
 
         QName qname = null;
         try {
@@ -1168,9 +1168,9 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
             qname = nodeType;
         }
 
-        SchemaPath path = stack.addNodeToPath(qname);
+        final SchemaPath path = stack.addNodeToPath(qname);
 
-        UnknownSchemaNodeBuilderImpl builder = moduleBuilder.addUnknownSchemaNode(line, qname, path);
+        final UnknownSchemaNodeBuilderImpl builder = moduleBuilder.addUnknownSchemaNode(line, qname, path);
         builder.setNodeType(nodeType);
         builder.setNodeParameter(nodeParameter);