A lot of our logic is implemented in terms of searching effective statements, mostly through StmtContextUtils methods. These go back way to Java 7 and those early days. We currently have Java 11 and possibility of default methods – and since these two reside in the same package the natural thing is to migrate over.
Optional<Boolean> findFirstSubstatementArgument(ConfigurationEffectiveStatement.class);
is what YANGTOOLS-783 is all about, I think.
This is a question InferredStatementContext can answer without materializing its substatements – at least for non-SchemaTreeEffectiveStatements we can just forward to prototype. For SchemaTreeEffectiveStatements we do a our->prototype namespace translation (the prototype knows its namespace) and again defer to prototype.
Let us also define a:
StmtContext.hasSubstatement(Class<? extends EffectiveStatement>)
Methods which need to use this method are:
StmtContextUtils.containsPresenceSubStmt() StmtContextUtil.hasAncestorOfTypeWithChildOfType() AbstractAugmentStatementSupport.hasWhenSubstatement()