import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.OnDemandSchemaTreeStorageNode;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextDefaults;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
import org.slf4j.Logger;
public <X, Z extends EffectiveStatement<X, ?>> @NonNull Optional<X> findSubstatementArgument(
final @NonNull Class<Z> type) {
if (substatements instanceof List) {
- return StmtContextDefaults.findSubstatementArgument(this, type);
+ return super.findSubstatementArgument(type);
}
final Optional<X> templateArg = prototype.findSubstatementArgument(type);
@Override
public boolean hasSubstatement(final @NonNull Class<? extends EffectiveStatement<?, ?>> type) {
- return substatements instanceof List ? StmtContextDefaults.hasSubstatement(prototype, type)
+ return substatements instanceof List ? super.hasSubstatement(type)
// We do not allow deletion of partially-materialized statements, hence this is accurate
: prototype.hasSubstatement(type);
}
@Override
- public <Y extends DeclaredStatement<QName>, Z extends EffectiveStatement<QName, Y>>
+ public <Y extends DeclaredStatement<QName>, Z extends SchemaTreeEffectiveStatement<Y>>
StmtContext<QName, Y, Z> requestSchemaTreeChild(final QName qname) {
if (substatements instanceof List) {
// We have performed materialization, hence we have triggered creation of all our schema tree child
@SuppressWarnings("unchecked")
final Mutable<QName, Y, Z> ret = (Mutable<QName, Y, Z>) copySubstatement((Mutable<?, ?, ?>) template)
- .orElseThrow(() -> new InferenceException(sourceReference(),
- "Failed to materialize child %s template %s", qname, template));
+ .orElseThrow(
+ () -> new InferenceException(this, "Failed to materialize child %s template %s", qname, template));
ensureCompletedPhase(ret);
addMaterialized(template, ret);
// Instantiate this statement's effective substatements. Note this method has side-effects in namespaces and overall
// BuildGlobalContext, hence it must be called at most once.
- private List<StatementContextBase<?, ?, ?>> ensureEffectiveSubstatements() {
+ private List<ReactorStmtCtx<?, ?, ?>> ensureEffectiveSubstatements() {
accessSubstatements();
return substatements instanceof List ? castEffective(substatements)
: initializeSubstatements(castMaterialized(substatements));
}
@Override
- Iterable<StatementContextBase<?, ?, ?>> effectiveChildrenToComplete() {
+ Iterable<ReactorStmtCtx<?, ?, ?>> effectiveChildrenToComplete() {
// When we have not initialized, there are no statements to catch up: we will catch up when we are copying
// from prototype (which is already at ModelProcessingPhase.EFFECTIVE_MODEL).
if (substatements == null) {
verify(substatements != SWEPT_SUBSTATEMENTS, "Attempted to access substatements of %s", this);
}
+ @Override
+ void markNoParentRef() {
+ final Object local = substatements;
+ if (local != null) {
+ markNoParentRef(castEffective(local));
+ }
+ }
+
@Override
int sweepSubstatements() {
final Object local = substatements;
substatements = SWEPT_SUBSTATEMENTS;
int count = 0;
if (local != null) {
- final List<StatementContextBase<?, ?, ?>> list = castEffective(local);
+ final List<ReactorStmtCtx<?, ?, ?>> list = castEffective(local);
sweep(list);
count = countUnswept(list);
}
return count;
}
- private List<StatementContextBase<?, ?, ?>> initializeSubstatements(
- final Map<StmtContext<?, ?, ?>, StatementContextBase<?, ?, ?>> materializedSchemaTree) {
+ private List<ReactorStmtCtx<?, ?, ?>> initializeSubstatements(
+ final Map<StmtContext<?, ?, ?>, ReactorStmtCtx<?, ?, ?>> materializedSchemaTree) {
final Collection<? extends StatementContextBase<?, ?, ?>> declared = prototype.mutableDeclaredSubstatements();
final Collection<? extends Mutable<?, ?, ?>> effective = prototype.mutableEffectiveSubstatements();
copySubstatement(stmtContext, buffer, materializedSchemaTree);
}
- final List<StatementContextBase<?, ?, ?>> ret = beforeAddEffectiveStatementUnsafe(ImmutableList.of(),
- buffer.size());
+ final List<ReactorStmtCtx<?, ?, ?>> ret = beforeAddEffectiveStatementUnsafe(ImmutableList.of(), buffer.size());
ret.addAll((Collection) buffer);
substatements = ret;
YangStmtMapping.USES);
private void copySubstatement(final Mutable<?, ?, ?> substatement, final Collection<Mutable<?, ?, ?>> buffer,
- final Map<StmtContext<?, ?, ?>, StatementContextBase<?, ?, ?>> materializedSchemaTree) {
+ final Map<StmtContext<?, ?, ?>, ReactorStmtCtx<?, ?, ?>> materializedSchemaTree) {
final StatementDefinition def = substatement.publicDefinition();
// FIXME: YANGTOOLS-652: formerly known as "isReusedByUses"
//
// We could also perform a Map.containsKey() and perform a bulk add, but that would mean the statement order
// against parent would change -- and we certainly do not want that to happen.
- final StatementContextBase<?, ?, ?> materialized = findMaterialized(materializedSchemaTree, substatement);
+ final ReactorStmtCtx<?, ?, ?> materialized = findMaterialized(materializedSchemaTree, substatement);
if (materialized == null) {
copySubstatement(substatement).ifPresent(copy -> {
ensureCompletedPhase(copy);
}
private void addMaterialized(final StmtContext<?, ?, ?> template, final Mutable<?, ?, ?> copy) {
- final HashMap<StmtContext<?, ?, ?>, StatementContextBase<?, ?, ?>> materializedSchemaTree;
+ final HashMap<StmtContext<?, ?, ?>, ReactorStmtCtx<?, ?, ?>> materializedSchemaTree;
if (substatements == null) {
// Lazy initialization of backing map. We do not expect this to be used often or multiple times -- each hit
// here means an inference along schema tree, such as deviate/augment. HashMap requires power-of-two and
}
}
- private static @Nullable StatementContextBase<?, ?, ?> findMaterialized(
- final Map<StmtContext<?, ?, ?>, StatementContextBase<?, ?, ?>> materializedSchemaTree,
+ private static @Nullable ReactorStmtCtx<?, ?, ?> findMaterialized(
+ final Map<StmtContext<?, ?, ?>, ReactorStmtCtx<?, ?, ?>> materializedSchemaTree,
final StmtContext<?, ?, ?> template) {
return materializedSchemaTree == null ? null : materializedSchemaTree.get(template);
}
@SuppressWarnings("unchecked")
- private static List<StatementContextBase<?, ?, ?>> castEffective(final Object substatements) {
- return (List<StatementContextBase<?, ?, ?>>) substatements;
+ private static List<ReactorStmtCtx<?, ?, ?>> castEffective(final Object substatements) {
+ return (List<ReactorStmtCtx<?, ?, ?>>) substatements;
}
@SuppressWarnings("unchecked")
- private static HashMap<StmtContext<?, ?, ?>, StatementContextBase<?, ?, ?>> castMaterialized(
- final Object substatements) {
- return (HashMap<StmtContext<?, ?, ?>, StatementContextBase<?, ?, ?>>) substatements;
+ private static HashMap<StmtContext<?, ?, ?>, ReactorStmtCtx<?, ?, ?>> castMaterialized(final Object substatements) {
+ return (HashMap<StmtContext<?, ?, ?>, ReactorStmtCtx<?, ?, ?>>) substatements;
}
// Statement copy mess ends here
*/
@Override
@Deprecated
- Optional<SchemaPath> schemaPath() {
+ public Optional<SchemaPath> schemaPath() {
return substatementGetSchemaPath();
}
}
@Override
- public boolean isConfiguration() {
- return isConfiguration(parent);
+ public EffectiveConfig effectiveConfig() {
+ return effectiveConfig(parent);
}
@Override