Eliminate parenthesis* variables 25/98125/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 25 Oct 2021 17:58:15 +0000 (19:58 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 25 Oct 2021 17:59:50 +0000 (19:59 +0200)
These three variables are in fact constant and record initial state --
i.e. they shadow two of the method's arguments. So let's remove them
them and create a startLevel variable to hold the initial set.

JIRA: NETCONF-820
Change-Id: Ic31bf706b28c94edd8e63159c62455422b2f890f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserFieldsParameter.java

index 8417229db5bb6f61781cc18ef82991651ef033cd..f4b7b77e9bb5d9d57065bd6d21181a65c45c904a 100644 (file)
@@ -153,17 +153,14 @@ public abstract class ParserFieldsParameter<T> {
     private void parseInput(final @NonNull String input, final @NonNull QNameModule startQNameModule,
                             final @NonNull DataSchemaContextNode<?> startNode,
                             final @NonNull List<Set<T>> parsed, final SchemaContext context) {
+        final Set<T> startLevel = new HashSet<>();
+        parsed.add(startLevel);
+
         int currentPosition = 0;
         int startPosition = 0;
         DataSchemaContextNode<?> currentNode = startNode;
         QNameModule currentQNameModule = startQNameModule;
-
-        Set<T> currentLevel = new HashSet<>();
-        parsed.add(currentLevel);
-
-        DataSchemaContextNode<?> parenthesisNode = currentNode;
-        Set<T> parenthesisLevel = currentLevel;
-        QNameModule parenthesisQNameModule = currentQNameModule;
+        Set<T> currentLevel = startLevel;
 
         while (currentPosition < input.length()) {
             final char currentChar = input.charAt(currentPosition);
@@ -235,9 +232,9 @@ public abstract class ParserFieldsParameter<T> {
                     currentPosition++;
 
                     // next nodes can be placed on already utilized level-s
-                    currentNode = parenthesisNode;
-                    currentQNameModule = parenthesisQNameModule;
-                    currentLevel = parenthesisLevel;
+                    currentNode = startNode;
+                    currentQNameModule = startQNameModule;
+                    currentLevel = startLevel;
                     break;
                 default:
                     throw new RestconfDocumentedException(