import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
-import org.opendaylight.yangtools.yang.parser.spi.SchemaTreeNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.ParserNamespaces;
import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStatementState;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
@Override
E createInferredEffective(final StatementFactory<A, D, E> factory, final InferredStatementContext<A, D, E> ctx,
- final Stream<? extends StmtContext<?, ?, ?>> declared,
- final Stream<? extends StmtContext<?, ?, ?>> effective) {
+ final Stream<? extends ReactorStmtCtx<?, ?, ?>> declared,
+ final Stream<? extends ReactorStmtCtx<?, ?, ?>> effective) {
return originalCtx.createInferredEffective(factory, ctx, declared, effective);
}
// ... copy-sensitive check
final List<EffectiveCopy> declCopy = prototype.streamDeclared()
- .map(sub -> effectiveCopy((ReactorStmtCtx<?, ?, ?>) sub))
+ .map(this::effectiveCopy)
.filter(Objects::nonNull)
.collect(Collectors.toUnmodifiableList());
final List<EffectiveCopy> effCopy = prototype.streamEffective()
- .map(sub -> effectiveCopy((ReactorStmtCtx<?, ?, ?>) sub))
+ .map(this::effectiveCopy)
.filter(Objects::nonNull)
.collect(Collectors.toUnmodifiableList());
return reusePrototypeReplicas(Streams.concat(prototype.streamDeclared(), prototype.streamEffective()));
}
- private List<ReactorStmtCtx<?, ?, ?>> reusePrototypeReplicas(final Stream<StmtContext<?, ?, ?>> stream) {
+ private List<ReactorStmtCtx<?, ?, ?>> reusePrototypeReplicas(final Stream<ReactorStmtCtx<?, ?, ?>> stream) {
return stream
.map(stmt -> {
- final ReplicaStatementContext<?, ?, ?> ret = ((ReactorStmtCtx<?, ?, ?>) stmt).replicaAsChildOf(this);
+ final var ret = stmt.replicaAsChildOf(this);
ret.buildEffective();
return ret;
})
}
private static boolean sameSubstatements(final Collection<?> original, final EffectiveStatement<?, ?> effective) {
- final Collection<?> copied = effective.effectiveSubstatements();
+ final var copied = effective.effectiveSubstatements();
if (copied != effective.effectiveSubstatements() || original.size() != copied.size()) {
// Do not bother if result is treating substatements as transient
return false;
}
- final Iterator<?> oit = original.iterator();
- final Iterator<?> cit = copied.iterator();
- while (oit.hasNext()) {
+ final var cit = copied.iterator();
+ for (var origChild : original) {
verify(cit.hasNext());
// Identity comparison on purpose to side-step whatever equality there might be. We want to reuse instances
// after all.
- if (oit.next() != cit.next()) {
+ if (origChild != cit.next()) {
return false;
}
}
if (prototype instanceof InferredStatementContext) {
// Note: we need to access namespace here, as the target statement may have already been populated, in which
// case we want to obtain the statement in local namespace storage.
- template = ((InferredStatementContext<?, ?, ?>) prototype).getFromNamespace(SchemaTreeNamespace.instance(),
+ template = ((InferredStatementContext<?, ?, ?>) prototype).getFromNamespace(ParserNamespaces.schemaTree(),
templateQName);
} else {
template = prototype.allSubstatementsStream()
}
@SuppressWarnings("unchecked")
- final Mutable<QName, Y, Z> ret = (Mutable<QName, Y, Z>) copySubstatement((Mutable<?, ?, ?>) template)
- .orElseThrow(
- () -> new InferenceException(this, "Failed to materialize child %s template %s", qname, template));
+ final var ret = (Mutable<QName, Y, Z>) copySubstatement(template).orElseThrow(
+ () -> new InferenceException(this, "Failed to materialize child %s template %s", qname, template));
addMaterialized(template, ensureCompletedPhase(ret));
LOG.debug("Child {} materialized", qname);
}
@Override
- Stream<? extends @NonNull StmtContext<?, ?, ?>> streamDeclared() {
+ Stream<? extends @NonNull ReactorStmtCtx<?, ?, ?>> streamDeclared() {
return Stream.empty();
}
@Override
- Stream<? extends @NonNull StmtContext<?, ?, ?>> streamEffective() {
+ Stream<? extends @NonNull ReactorStmtCtx<?, ?, ?>> streamEffective() {
return ensureEffectiveSubstatements().stream().filter(StmtContext::isSupportedToBuildEffective);
}
}
}
- private Optional<? extends Mutable<?, ?, ?>> copySubstatement(final Mutable<?, ?, ?> substatement) {
+ private <X, Y extends DeclaredStatement<X>, Z extends EffectiveStatement<X, Y>> Optional<Mutable<X, Y, Z>>
+ copySubstatement(final StmtContext<X, Y, Z> substatement) {
return substatement.copyAsChildOf(this, childCopyType(), targetModule);
}