Defer statement initialization in InferredStatementContext (YANGTOOLS-784)

[YANGTOOLS-1157] Add StmtContext.findSubstatementArgument() Created: 29/Oct/20  Updated: 06/Nov/20  Resolved: 31/Oct/20

Status: Resolved
Project: yangtools
Component/s: parser
Affects Version/s: None
Fix Version/s: 6.0.1, 5.0.8

Type: Sub-task Priority: Medium
Reporter: Robert Varga Assignee: Miroslav Kovac
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

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()
 

 

 

 


Generated at Wed Feb 07 20:55:21 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.