private final @NonNull StatementDefinitionContext<A, D, E> definition;
private final @NonNull StatementSourceReference statementDeclSource;
private final StmtContext<?, ?, ?> originalCtx;
+ private final StmtContext<?, ?, ?> prevCopyCtx;
private final CopyHistory copyHistory;
private final String rawArgument;
this.rawArgument = def.internArgument(rawArgument);
this.copyHistory = CopyHistory.original();
this.originalCtx = null;
+ this.prevCopyCtx = null;
}
StatementContextBase(final StatementDefinitionContext<A, D, E> def, final StatementSourceReference ref,
this.rawArgument = rawArgument;
this.copyHistory = CopyHistory.of(copyType, CopyHistory.original());
this.originalCtx = null;
+ this.prevCopyCtx = null;
}
StatementContextBase(final StatementContextBase<A, D, E> original, final CopyType copyType) {
this.rawArgument = original.rawArgument;
this.copyHistory = CopyHistory.of(copyType, original.getCopyHistory());
this.originalCtx = original.getOriginalCtx().orElse(original);
+ this.prevCopyCtx = original;
}
StatementContextBase(final StatementContextBase<A, D, E> original) {
this.rawArgument = original.rawArgument;
this.copyHistory = original.getCopyHistory();
this.originalCtx = original.getOriginalCtx().orElse(original);
+ this.prevCopyCtx = original;
this.substatements = original.substatements;
this.effective = original.effective;
}
// If the set of supported features has not been provided, all features are supported by default.
final Set<QName> supportedFeatures = getFromNamespace(SupportedFeaturesNamespace.class,
SupportedFeatures.SUPPORTED_FEATURES);
- final boolean ret = supportedFeatures == null ? true
- : StmtContextUtils.checkFeatureSupport(this, supportedFeatures);
-
+ final boolean ret = supportedFeatures == null || StmtContextUtils.checkFeatureSupport(this, supportedFeatures);
supportedByFeatures = OptionalBoolean.of(ret);
return ret;
}
return Optional.ofNullable(originalCtx);
}
+ @Override
+ public Optional<? extends StmtContext<?, ?, ?>> getPreviousCopyCtx() {
+ return Optional.ofNullable(prevCopyCtx);
+ }
+
@Override
public ModelProcessingPhase getCompletedPhase() {
return completedPhase;
return Collections.unmodifiableCollection(effective);
}
+ /**
+ * Remove a set of statements from effective statements.
+ *
+ * @param statements statements to be removed
+ * @deprecated This method was used by EffectiveStatementBase to restore proper order of effects of uses statements.
+ * It is no longer used in that capacity and slated for removal.
+ */
+ // FIXME: 5.0.0: remove this method
+ @Deprecated
public void removeStatementsFromEffectiveSubstatements(
final Collection<? extends StmtContext<?, ?, ?>> statements) {
if (!effective.isEmpty()) {
copy = new SubstatementContext<>(original, result, childCopyType, targetModule);
result.addEffectiveSubstatement(copy);
- original.definition().onStatementAdded(copy);
} else {
result = copy = new SubstatementContext<>(original, this, type, targetModule);
- original.definition().onStatementAdded(copy);
}
+ original.definition().onStatementAdded(copy);
original.copyTo(copy, type, targetModule);
return result;
}
}
// FIXME: revise this, as it seems to be wrong
- private static final Set<YangStmtMapping> NOCOPY_FROM_GROUPING_SET = ImmutableSet.of(
+ private static final ImmutableSet<YangStmtMapping> NOCOPY_FROM_GROUPING_SET = ImmutableSet.of(
YangStmtMapping.DESCRIPTION,
YangStmtMapping.REFERENCE,
YangStmtMapping.STATUS);
- private static final Set<YangStmtMapping> REUSED_DEF_SET = ImmutableSet.of(
+ private static final ImmutableSet<YangStmtMapping> REUSED_DEF_SET = ImmutableSet.of(
YangStmtMapping.TYPE,
YangStmtMapping.TYPEDEF,
YangStmtMapping.USES);