Split StmtContextUtils.hasParentOfType() implementations
[yangtools.git] / 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());
     }
 
     /**