Disconnect yang-data-util from concepts.Builder 49/99349/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 18 Jan 2022 08:49:11 +0000 (09:49 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 18 Jan 2022 08:50:09 +0000 (09:50 +0100)
The Builder concept is going away, do not use it during XPath parsing.

JIRA: YANGTOOLS-1328
Change-Id: I4f9547d38d8786f7b9b771f264f6e941c11fb089
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
data/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/XpathStringParsingPathArgumentBuilder.java

index d9f2f516b045cdc147ce9f1cfbba8be826348506..11b54ddc1e7e78c09fb5d3830bf344bde1a66531 100644 (file)
@@ -15,7 +15,7 @@ import com.google.common.collect.ImmutableMap;
 import java.util.ArrayList;
 import java.util.List;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.concepts.Mutable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -34,8 +34,7 @@ import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
  * is not correctly serialized or does not represent instance identifier valid
  * for associated schema context.
  */
-final class XpathStringParsingPathArgumentBuilder implements Builder<List<PathArgument>> {
-
+final class XpathStringParsingPathArgumentBuilder implements Mutable {
     /**
      * Matcher matching WSP YANG ABNF token.
      */
@@ -74,15 +73,20 @@ final class XpathStringParsingPathArgumentBuilder implements Builder<List<PathAr
     XpathStringParsingPathArgumentBuilder(final AbstractStringInstanceIdentifierCodec codec, final String data) {
         this.codec = requireNonNull(codec);
         this.data = requireNonNull(data);
-        this.offset = 0;
+        offset = 0;
 
         final DataSchemaContextTree tree = codec.getDataContextTree();
-        this.stack = SchemaInferenceStack.of(tree.getEffectiveModelContext());
-        this.current = tree.getRoot();
+        stack = SchemaInferenceStack.of(tree.getEffectiveModelContext());
+        current = tree.getRoot();
     }
 
-    @Override
-    public List<PathArgument> build() {
+    /**
+     * Parse input string and return the corresponding list of {@link PathArgument}s.
+     *
+     * @return List of PathArguments
+     * @throws IllegalArgumentException if the input string is not valid
+     */
+    @NonNull List<PathArgument> build() {
         while (!allCharactersConsumed()) {
             product.add(computeNextArgument());
         }