Move validArg() 28/83328/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 31 Jul 2019 00:00:55 +0000 (02:00 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 2 Aug 2019 17:33:11 +0000 (17:33 +0000)
This method has a single caller, which just passes it the state --
which really makes the method an instance method.

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

index 5577aa181a83847949c9c8bb47c3287e79ebaf4f..7f73387d1072785eeaa017a013da11233abe998f 100644 (file)
@@ -79,7 +79,7 @@ public final class YangInstanceIdentifierDeserializer {
                 YangInstanceIdentifierDeserializer.MainVarsWrapper.STARTING_OFFSET, schemaContext);
 
         while (!variables.allCharsConsumed()) {
-            validArg(variables);
+            variables.validArg();
             final QName qname = prepareQName(variables);
 
             // this is the last identifier (input is consumed) or end of identifier (slash)
@@ -384,22 +384,6 @@ public final class YangInstanceIdentifierDeserializer {
         return schemaContext.findModules(prefix).stream().findFirst().orElse(null);
     }
 
-    private static void validArg(final MainVarsWrapper variables) {
-        // every identifier except of the first MUST start with slash
-        if (variables.getOffset() != MainVarsWrapper.STARTING_OFFSET) {
-            variables.checkValid(RestconfConstants.SLASH == variables.currentChar(), "Identifier must start with '/'.");
-
-            // skip consecutive slashes, users often assume restconf URLs behave just as HTTP does by squashing
-            // multiple slashes into a single one
-            while (!variables.allCharsConsumed() && RestconfConstants.SLASH == variables.currentChar()) {
-                variables.skipCurrentChar();
-            }
-
-            // check if slash is not also the last char in identifier
-            variables.checkValid(!variables.allCharsConsumed(), "Identifier cannot end with '/'.");
-        }
-    }
-
     private static Optional<ActionDefinition> findActionDefinition(final SchemaNode dataSchemaNode,
             final String nodeName) {
         requireNonNull(dataSchemaNode, "DataSchema Node must not be null.");
@@ -452,6 +436,22 @@ public final class YangInstanceIdentifierDeserializer {
             return data.substring(start, offset);
         }
 
+        void validArg() {
+            // every identifier except of the first MUST start with slash
+            if (offset != MainVarsWrapper.STARTING_OFFSET) {
+                checkValid(RestconfConstants.SLASH == currentChar(), "Identifier must start with '/'.");
+
+                // skip consecutive slashes, users often assume restconf URLs behave just as HTTP does by squashing
+                // multiple slashes into a single one
+                while (!allCharsConsumed() && RestconfConstants.SLASH == currentChar()) {
+                    skipCurrentChar();
+                }
+
+                // check if slash is not also the last char in identifier
+                checkValid(!allCharsConsumed(), "Identifier cannot end with '/'.");
+            }
+        }
+
         public DataSchemaContextNode<?> getCurrent() {
             return current;
         }