Remove SchemaUtils.findParentSchemaNodesOnPath() 13/95113/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 10 Feb 2021 13:03:07 +0000 (14:03 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 10 Feb 2021 13:18:58 +0000 (14:18 +0100)
These methods are not used anywhere except tests, remove them now.

JIRA: YANGTOOLS-1230
Change-Id: I3ca3d7bd7bf1e6f27fea634ee138d3f1769e5666
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/SchemaUtils.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/SchemaUtilsTest.java [deleted file]
yang/yang-data-impl/src/test/resources/schema-utils-test/foo.yang [deleted file]
yang/yang-data-impl/src/test/resources/schema-utils-test/name-conflicts.yang [deleted file]

index 6385e83984f93ae08e4fc4e667884331531342b2..5182db1eccf7e0a962c3de364ea63415fc6f9800 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
 import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
 
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
@@ -39,7 +38,6 @@ import org.opendaylight.yangtools.yang.model.api.NotificationNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.OperationDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 public final class SchemaUtils {
     private SchemaUtils() {
@@ -392,26 +390,6 @@ public final class SchemaUtils {
         return null;
     }
 
-    /**
-     * Finds schema node for given path in schema context. This method performs
-     * lookup in the namespace of all leafs, leaf-lists, lists, containers,
-     * choices, rpcs, actions, notifications, anydatas, and anyxmls according to
-     * Rfc6050/Rfc7950 section 6.2.1.
-     *
-     * @param schemaContext
-     *            schema context
-     * @param path
-     *            path
-     * @return schema node on path
-     */
-    public static SchemaNode findDataParentSchemaOnPath(final SchemaContext schemaContext, final SchemaPath path) {
-        SchemaNode current = requireNonNull(schemaContext);
-        for (final QName qname : path.getPathFromRoot()) {
-            current = findDataChildSchemaByQName(current, qname);
-        }
-        return current;
-    }
-
     /**
      * Find child data schema node identified by its QName within a provided schema node. This method performs lookup
      * in the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions, notifications, anydatas
@@ -457,58 +435,6 @@ public final class SchemaUtils {
         throw new IllegalArgumentException(String.format("Schema node %s does not allow children.", node));
     }
 
-    /**
-     * Finds schema node for given path in schema context. This method performs lookup in both the namespace
-     * of groupings and the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions,
-     * notifications, anydatas and anyxmls according to Rfc6050/Rfc7950 section 6.2.1.
-     *
-     * <p>
-     * This method returns collection of SchemaNodes, because name conflicts can occur between the namespace
-     * of groupings and namespace of data nodes. This method finds and collects all schema nodes that matches supplied
-     * SchemaPath and returns them all as collection of schema nodes.
-     *
-     * @param schemaContext
-     *            schema context
-     * @param path
-     *            path
-     * @return collection of schema nodes on path
-     */
-    public static Collection<SchemaNode> findParentSchemaNodesOnPath(final SchemaContext schemaContext,
-            final SchemaPath path) {
-        return findParentSchemaNodesOnPath(schemaContext, path.getPathFromRoot());
-    }
-
-    /**
-     * Finds schema node for given path in schema context. This method performs lookup in both the namespace
-     * of groupings and the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions,
-     * notifications, anydatas and anyxmls according to Rfc6050/Rfc7950 section 6.2.1.
-     *
-     * <p>
-     * This method returns collection of SchemaNodes, because name conflicts can occur between the namespace
-     * of groupings and namespace of data nodes. This method finds and collects all schema nodes that matches supplied
-     * SchemaPath and returns them all as collection of schema nodes.
-     *
-     * @param schemaContext schema context
-     * @param path path
-     * @return collection of schema nodes on path
-     */
-    public static Collection<SchemaNode> findParentSchemaNodesOnPath(final SchemaContext schemaContext,
-            final Iterable<QName> path) {
-        final Collection<SchemaNode> currentNodes = new ArrayList<>();
-        final Collection<SchemaNode> childNodes = new ArrayList<>();
-        currentNodes.add(requireNonNull(schemaContext));
-        for (final QName qname : path) {
-            for (final SchemaNode current : currentNodes) {
-                childNodes.addAll(findChildSchemaNodesByQName(current, qname));
-            }
-            currentNodes.clear();
-            currentNodes.addAll(childNodes);
-            childNodes.clear();
-        }
-
-        return currentNodes;
-    }
-
     /**
      * Find child schema node identified by its QName within a provided schema node. This method performs lookup in both
      * the namespace of groupings and the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs,
diff --git a/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/SchemaUtilsTest.java b/yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/SchemaUtilsTest.java
deleted file mode 100644 (file)
index b04b831..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2017 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.data.impl.schema;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collection;
-import org.junit.Test;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-
-public class SchemaUtilsTest {
-    private static final String NS = "my-namespace";
-
-    @Test
-    public void test() {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/schema-utils-test/foo.yang");
-        assertTrue(SchemaUtils.findDataParentSchemaOnPath(schemaContext,
-                SchemaPath.create(true, qN("my-name"), qN("my-name-a"))) instanceof ContainerSchemaNode);
-        assertTrue(SchemaUtils.findDataParentSchemaOnPath(schemaContext,
-                SchemaPath.create(true, qN("my-name-2"), qN("my-name-b"))) instanceof NotificationDefinition);
-        assertTrue(SchemaUtils.findDataParentSchemaOnPath(schemaContext,
-                SchemaPath.create(true, qN("my-name-2"), qN("my-name-2-b"))) instanceof ActionDefinition);
-    }
-
-    @Test
-    public void testNameConflicts() {
-        final SchemaContext schemaContext = YangParserTestUtils
-                .parseYangResource("/schema-utils-test/name-conflicts.yang");
-        // test my-name conflicts
-        assertEquals(8, SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
-                SchemaPath.create(true, qN("my-name"), qN("my-name-nested"), qN("my-name-nested2"))).size());
-
-        // test target container
-        final Collection<SchemaNode> target = SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
-                SchemaPath.create(true, qN("my-name-2"), qN("my-name-nested"), qN("target")));
-        assertEquals(1, target.size());
-        assertTrue(target.iterator().next() instanceof ContainerSchemaNode);
-
-        // test l schema nodes (i.e. container and two leafs)
-        Collection<SchemaNode> schema = SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
-                SchemaPath.create(true, qN("my-name-3"), qN("input"), qN("con-3"), qN("l")));
-        assertEquals(1, schema.size());
-        assertTrue(schema.iterator().next() instanceof ContainerSchemaNode);
-
-        schema = SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
-                SchemaPath.create(true, qN("my-name-3"), qN("input"), qN("con-1"), qN("l")));
-        assertEquals(1, schema.size());
-        assertTrue(schema.iterator().next() instanceof LeafSchemaNode);
-
-        schema = SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
-                SchemaPath.create(true, qN("my-name-3"), qN("input"), qN("con-2"), qN("l")));
-        assertTrue(schema.isEmpty());
-
-        schema = SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
-                SchemaPath.create(true, qN("my-name-3"), qN("output"), qN("con-2"), qN("l")));
-        assertEquals(1, schema.size());
-        assertTrue(schema.iterator().next() instanceof LeafSchemaNode);
-    }
-
-    private static QName qN(final String localName) {
-        return QName.create(NS, localName);
-    }
-}
diff --git a/yang/yang-data-impl/src/test/resources/schema-utils-test/foo.yang b/yang/yang-data-impl/src/test/resources/schema-utils-test/foo.yang
deleted file mode 100644 (file)
index abd079b..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-module foo {
-    namespace my-namespace;
-    prefix p;
-    yang-version 1.1;
-
-    feature my-name;
-
-    identity my-name;
-
-    extension my-name;
-
-    typedef my-name {
-        type string;
-    }
-
-    grouping my-name {
-    }
-
-    grouping my-name-2 {
-    }
-
-    notification my-name {
-        grouping my-name-a {
-        }
-        container my-name-a {
-        }
-    }
-
-    container my-name-2 {
-        grouping my-name-b {
-        }
-        notification my-name-b {
-        }
-        grouping my-name-2-b {
-        }
-        action my-name-2-b {
-        }
-    }
-}
diff --git a/yang/yang-data-impl/src/test/resources/schema-utils-test/name-conflicts.yang b/yang/yang-data-impl/src/test/resources/schema-utils-test/name-conflicts.yang
deleted file mode 100644 (file)
index bc51627..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-module name-conflicts {
-    namespace "my-namespace";
-    prefix nc;
-
-    grouping my-name {
-        grouping my-name-nested {
-            grouping my-name-nested2 {
-            }
-            container my-name-nested2 {
-            }
-        }
-        container my-name-nested {
-            grouping my-name-nested2 {
-            }
-            container my-name-nested2 {
-            }
-        }
-    }
-
-    container my-name {
-        grouping my-name-nested {
-            grouping my-name-nested2 {
-            }
-            container my-name-nested2 {
-            }
-        }
-        container my-name-nested {
-            grouping my-name-nested2 {
-            }
-            container my-name-nested2 {
-            }
-        }
-    }
-
-    grouping my-name-2 {
-        grouping my-name-nested {
-            grouping my-name-nested2 {
-            }
-            container my-name-nested2 {
-            }
-        }
-        container my-name-2 {
-            grouping my-name-nested2 {
-            }
-            container my-name-nested2 {
-            }
-        }
-    }
-
-    container my-name-2 {
-        grouping my-name-nested {
-            grouping my-name-nested2 {
-            }
-            container target {
-            }
-        }
-        container my-name-nested {
-            grouping my-name-nested2 {
-            }
-            container my-name-nested2 {
-            }
-        }
-    }
-
-    rpc my-name-3 {
-        input {
-            container con-1 {
-                leaf l {
-                    type string;
-                }
-            }
-        }
-        output {
-            container con-2 {
-                leaf l {
-                    type string;
-                }
-            }
-        }
-    }
-
-    grouping my-name-3 {
-        container input {
-            container con-3 {
-                container l {
-                }
-            }
-        }
-    }
-}