X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=parser%2Fyang-parser-reactor%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Freactor%2FInferredStatementContext.java;h=f5a00a14991712bb0e2bf6001c6be3ed561458e4;hb=157a6df3f39ea0418076426114f1c23a0415dd80;hp=9349e3ff6ca2b5c6f31d462e85b96cc19c810075;hpb=4a6530a763abf6bff5eebaa3c7ac126bedfea888;p=yangtools.git diff --git a/parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/InferredStatementContext.java b/parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/InferredStatementContext.java index 9349e3ff6c..f5a00a1499 100644 --- a/parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/InferredStatementContext.java +++ b/parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/InferredStatementContext.java @@ -463,8 +463,7 @@ final class InferredStatementContext, E extend final Mutable ret = (Mutable) copySubstatement((Mutable) template) .orElseThrow( () -> new InferenceException(this, "Failed to materialize child %s template %s", qname, template)); - ensureCompletedPhase(ret); - addMaterialized(template, ret); + addMaterialized(template, ensureCompletedPhase(ret)); LOG.debug("Child {} materialized", qname); return ret; @@ -535,7 +534,7 @@ final class InferredStatementContext, E extend final Collection> declared = prototype.mutableDeclaredSubstatements(); final Collection> effective = prototype.mutableEffectiveSubstatements(); - final List> buffer = new ArrayList<>(declared.size() + effective.size()); + final var buffer = new ArrayList>(declared.size() + effective.size()); for (final Mutable stmtContext : declared) { if (stmtContext.isSupportedByFeatures()) { copySubstatement(stmtContext, buffer, materializedSchemaTree); @@ -546,7 +545,7 @@ final class InferredStatementContext, E extend } final List> ret = beforeAddEffectiveStatementUnsafe(ImmutableList.of(), buffer.size()); - ret.addAll((Collection) buffer); + ret.addAll(buffer); substatements = ret; setModified(); @@ -564,7 +563,7 @@ final class InferredStatementContext, E extend return effective == null ? null : new EffectiveCopy(stmt, effective); } - private void copySubstatement(final Mutable substatement, final Collection> buffer, + private void copySubstatement(final Mutable substatement, final Collection> buffer, final Map, ReactorStmtCtx> materializedSchemaTree) { // Consult materialized substatements. We are in a copy operation and will end up throwing materialized // statements away -- hence we do not perform Map.remove() to save ourselves a mutation operation. @@ -574,8 +573,7 @@ final class InferredStatementContext, E extend final ReactorStmtCtx materialized = findMaterialized(materializedSchemaTree, substatement); if (materialized == null) { copySubstatement(substatement).ifPresent(copy -> { - ensureCompletedPhase(copy); - buffer.add(copy); + buffer.add(ensureCompletedPhase(copy)); }); } else { buffer.add(materialized); @@ -586,7 +584,7 @@ final class InferredStatementContext, E extend return substatement.copyAsChildOf(this, childCopyType(), targetModule); } - private void addMaterialized(final StmtContext template, final Mutable copy) { + private void addMaterialized(final StmtContext template, final ReactorStmtCtx copy) { final HashMap, ReactorStmtCtx> materializedSchemaTree; if (substatements == null) { // Lazy initialization of backing map. We do not expect this to be used often or multiple times -- each hit @@ -601,8 +599,7 @@ final class InferredStatementContext, E extend materializedSchemaTree = castMaterialized(substatements); } - final StmtContext existing = materializedSchemaTree.put(template, - (StatementContextBase) copy); + final var existing = materializedSchemaTree.put(template, copy); if (existing != null) { throw new VerifyException( "Unexpected duplicate request for " + copy.argument() + " previous result was " + existing);