Split StmtContextUtils.hasParentOfType() implementations 24/94624/4
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 13 Jan 2021 22:00:57 +0000 (23:00 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 14 Jan 2021 10:19:14 +0000 (11:19 +0100)
EffectiveStmtCtx.Current version on this method is deferring to
the StmtContext version. That is not needed, as EffectiveStmtCtx
gives us everything we need.

JIRA: YANGTOOLS-1186
Change-Id: I8eedc34c6513b8aa6825ba8b63171111379f03ce
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextUtils.java

index 8aaad4478c78a9ba81d70d04fb717b69ed4c9b8b..90d7311c3adf34c08ccabf12be5406e9672387f2 100644 (file)
@@ -388,11 +388,13 @@ public final class StmtContextUtils {
      *
      * @param stmt EffectiveStmtCtx to be checked
      * @param parentType type of parent to check
-     * @return true if the parent of StmtContext is of specified type, otherwise false
+     * @return true if the parent statement of {@code stmt} is of specified type, otherwise false
+     * @throws NullPointerException if any argument is {@code null}
      */
-    public static boolean hasParentOfType(final EffectiveStmtCtx.Current<?, ?> stmt,
-            final StatementDefinition parentType) {
-        return hasParentOfType(stmt.caerbannog(), parentType);
+    public static boolean hasParentOfType(final EffectiveStmtCtx stmt, final StatementDefinition parentType) {
+        requireNonNull(parentType);
+        final Parent parent = stmt.effectiveParent();
+        return parent != null && parentType.equals(parent.publicDefinition());
     }
 
     /**