Remove DataSchemaContextTree.getChild() 30/92230/6
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 21 Aug 2020 08:29:01 +0000 (10:29 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 22 Aug 2020 10:30:38 +0000 (12:30 +0200)
This method has been superseded by findChild(), remove it now.

Change-Id: Ic478bce28e6c99d830ae2a42fca88c5bd3c970a6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/DataSchemaContextTree.java
yang/yang-data-util/src/test/java/org/opendaylight/yangtools/yang/data/util/codec/DataSchemaContextTreeTest.java

index 6d55e77745b5b8a4cfbc069f3833606a2611883f..db2ea28e33a77e3f028ef5016ef03e70d1c927ba 100644 (file)
@@ -12,9 +12,7 @@ import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
@@ -55,27 +53,6 @@ public final class DataSchemaContextTree {
         return getRoot().findChild(path);
     }
 
-    /**
-     * Get a child node as identified by an absolute {@link YangInstanceIdentifier}.
-     *
-     * @param path Path towards the child node
-     * @return Child node if present, or null when corresponding child is not found.
-     * @throws NullPointerException if {@code path} is null
-     *
-     * @deprecated Use {@link #findChild(YangInstanceIdentifier)} instead.
-     */
-    @Deprecated(forRemoval = true)
-    public @Nullable DataSchemaContextNode<?> getChild(final YangInstanceIdentifier path) {
-        DataSchemaContextNode<?> currentOp = root;
-        for (PathArgument arg : path.getPathArguments()) {
-            currentOp = currentOp.getChild(arg);
-            if (currentOp == null) {
-                return null;
-            }
-        }
-        return currentOp;
-    }
-
     public DataSchemaContextNode<?> getRoot() {
         return root;
     }
index cca8dcd33622cb55f9c08e57d8c65f76a7431f4b..7c9048e2c32c1f34604106a0d8f5636be7c004fc 100644 (file)
@@ -8,8 +8,6 @@
 package org.opendaylight.yangtools.yang.data.util.codec;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.net.URI;
@@ -45,21 +43,15 @@ public class DataSchemaContextTreeTest {
         assertTrue(CONTEXT.findChild(YangInstanceIdentifier.of(FOO)).isPresent());
         assertTrue(CONTEXT.findChild(YangInstanceIdentifier.of(FOO).node(BAR)).isPresent());
         assertTrue(CONTEXT.findChild(YangInstanceIdentifier.of(FOO).node(BAR).node(BAZ)).isPresent());
-
-        assertNotNull(CONTEXT.getChild(YangInstanceIdentifier.of(FOO)));
-        assertNotNull(CONTEXT.getChild(YangInstanceIdentifier.of(FOO).node(BAR)));
-        assertNotNull(CONTEXT.getChild(YangInstanceIdentifier.of(FOO).node(BAR).node(BAZ)));
     }
 
     @Test
     public void testSimpleBad() {
         assertEquals(Optional.empty(), CONTEXT.findChild(YangInstanceIdentifier.of(BAR)));
-        assertNull(CONTEXT.getChild(YangInstanceIdentifier.of(BAR)));
     }
 
     @Test
     public void testNestedBad() {
         assertEquals(Optional.empty(), CONTEXT.findChild(YangInstanceIdentifier.of(BAR).node(BAZ)));
-        assertNull(CONTEXT.getChild(YangInstanceIdentifier.of(BAR).node(BAZ)));
     }
 }