return (StatementPolicy<A, D>) EqualSemantics.CONTEXT_INDEPENDENT;
}
+ /**
+ * Return a {@link StatementPolicy} for {@link CopyPolicy#EXACT_REPLICA}.
+ *
+ * @param <A> Argument type
+ * @param <D> Declared Statement representation
+ * @return Exact-replica policy
+ */
+ @SuppressWarnings("unchecked")
+ public static final <A, D extends DeclaredStatement<A>> @NonNull StatementPolicy<A, D> exactReplica() {
+ return (StatementPolicy<A, D>) EqualSemantics.EXACT_REPLICA;
+ }
+
/**
* Return a {@link StatementPolicy} for {@link CopyPolicy#IGNORE}.
*
return (StatementPolicy<A, D>) EqualSemantics.ALWAYS_COPY;
}
- @Deprecated(forRemoval = true)
- // FIXME: 7.0.0: remove this method
- public static final <A, D extends DeclaredStatement<A>> @NonNull StatementPolicy<A, D> legacyDeclaredCopy() {
- return alwaysCopyDeclared();
- }
-
abstract boolean canReuseCurrent(@NonNull Current<A, D> copy, @NonNull Current<A, D> current,
@NonNull Collection<? extends EffectiveStatement<?, ?>> substatements);
new EqualSemantics<>((copy, stmt, substatements) -> false);
static final @NonNull EqualSemantics<?, ?> CONTEXT_INDEPENDENT =
new EqualSemantics<>(CopyPolicy.CONTEXT_INDEPENDENT, (copy, stmt, substatements) -> true);
+ static final @NonNull EqualSemantics<?, ?> EXACT_REPLICA =
+ new EqualSemantics<>(CopyPolicy.EXACT_REPLICA, (copy, stmt, substatements) -> true);
private final @NonNull StatementEquality<A, D> equality;
*
* <p>
* Implementation may use method to perform actions on this event or register modification action using
- * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}.
+ * {@link Mutable#newInferenceAction(ModelProcessingPhase)}.
*
* @param stmt Context of added statement.
* @throws SourceException when an inconsistency is detected.
*
* <p>
* Implementation may use method to perform actions on this event or register modification action using
- * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}.
+ * {@link Mutable#newInferenceAction(ModelProcessingPhase)}.
*
* @param stmt Context of added statement. Argument and statement parent is accessible.
* @throws SourceException when an inconsistency is detected.
*
* <p>
* Implementation may use method to perform actions on this event or register modification action using
- * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}.
+ * {@link Mutable#newInferenceAction(ModelProcessingPhase)}.
*
* @param stmt Context of added statement. Argument and statement parent is accessible.
* @throws SourceException when an inconsistency is detected.
*/
- public void onFullDefinitionDeclared(final StmtContext.Mutable<A, D, E> stmt) {
- final SubstatementValidator validator = getSubstatementValidator();
+ public void onFullDefinitionDeclared(final Mutable<A, D, E> stmt) {
+ final SubstatementValidator validator = substatementValidator();
if (validator != null) {
validator.validate(stmt);
}
*
* @return substatement validator or null, if substatement validator is not defined
*/
- // FIXME: rename to 'substatementValidator' and perhaps let it be passed in?
- protected abstract @Nullable SubstatementValidator getSubstatementValidator();
+ protected abstract @Nullable SubstatementValidator substatementValidator();
/**
* Returns true if this support has argument specific supports.
+ *
+ * @return true if this support has argument specific supports.
*/
public boolean hasArgumentSpecificSupports() {
// Most of statement supports don't have any argument specific supports, so return 'false'.
return rawArgument;
}
- /**
- * Returns unknown statement form of a regular YANG statement supplied as a parameter to the method. Default
- * implementation does nothing.
- *
- * @param yangStmtDef statement definition of a regular YANG statement
- * @return Optional of unknown statement form of a regular YANG statement or empty() if it is not supported by this
- * statement support
- */
- public Optional<StatementSupport<?, ?, ?>> getUnknownStatementDefinitionOf(final StatementDefinition yangStmtDef) {
- return Optional.empty();
- }
-
/**
* Returns true if this statement support and all its substatements ignore if-feature statements (e.g. yang-data
* extension defined in <a href="https://tools.ietf.org/html/rfc8040#section-8">RFC 8040</a>). Default
*/
// TODO: does this mean source must have transitioned to ModelProcessingPhase.EFFECTIVE_MODEL?
CONTEXT_INDEPENDENT,
+ /**
+ * Reuse the source statement context in the new place completely. This policy is more stringent than
+ * {@link #CONTEXT_INDEPENDENT} in that the statement is dependent on circumstances of its original definition
+ * and any copy operation must replicate it exactly as is. This implies ignoring the usual policy of its
+ * substatements. A typical example of such a statement is {@code type}.
+ */
+ EXACT_REPLICA,
/**
* Create a copy sharing declared instance, but otherwise having a separate disconnected lifecycle.
*/