private static boolean isRelevantForIfFeatureAndWhenOnListKeysCheck(final StmtContext<?, ?, ?> ctx) { return YangVersion.VERSION_1_1.equals(ctx.getRootVersion()) && StmtContextUtils.hasParentOfType(ctx, YangStmtMapping.LIST) && StmtContextUtils.findFirstDeclaredSubstatement(ctx.coerceParentContext(), KeyStatement.class) != null; }
@Override public EffectiveStatement<QName, ActionStatement> createEffective( final StmtContext<QName, ActionStatement, EffectiveStatement<QName, ActionStatement>> ctx) { SourceException.throwIf(StmtContextUtils.hasAncestorOfType(ctx, ILLEGAL_PARENTS), ctx.getStatementSourceReference(), "Action %s is defined within a notification, rpc or another action", ctx.getStatementArgument()); SourceException.throwIf(!StmtContextUtils.hasAncestorOfTypeWithChildOfType(ctx, YangStmtMapping.LIST, YangStmtMapping.KEY), ctx.getStatementSourceReference(), "Action %s is defined within a list that has no key statement", ctx.getStatementArgument()); SourceException.throwIf(StmtContextUtils.hasParentOfType(ctx, YangStmtMapping.CASE), ctx.getStatementSourceReference(), "Action %s is defined within a case statement", ctx.getStatementArgument()); SourceException.throwIf(StmtContextUtils.hasParentOfType(ctx, YangStmtMapping.MODULE), ctx.getStatementSourceReference(), "Action %s is defined at the top level of a module", ctx.getStatementArgument()); return new ActionEffectiveStatementImpl(ctx); }
@Override public EffectiveStatement<QName, NotificationStatement> createEffective( final StmtContext<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> ctx) { SourceException.throwIf(StmtContextUtils.hasAncestorOfType(ctx, ILLEGAL_PARENTS), ctx.getStatementSourceReference(), "Notification %s is defined within an rpc, action, or another notification", ctx.getStatementArgument()); SourceException.throwIf(!StmtContextUtils.hasAncestorOfTypeWithChildOfType(ctx, YangStmtMapping.LIST, YangStmtMapping.KEY), ctx.getStatementSourceReference(), "Notification %s is defined within a list that has no key statement", ctx.getStatementArgument()); SourceException.throwIf(StmtContextUtils.hasParentOfType(ctx, YangStmtMapping.CASE), ctx.getStatementSourceReference(), "Notification %s is defined within a case statement", ctx.getStatementArgument()); return new NotificationEffectiveStatementImpl(ctx); }