import com.google.common.collect.Iterables;
import com.google.common.collect.Streams;
import java.util.Collection;
-import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNull;
* @param <E> Effective Statement representation
*/
public interface StmtContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
- extends BoundStmtCtx<A> {
+ extends NamespaceStmtCtx, BoundStmtCtxCompat<A, D> {
@Deprecated(forRemoval = true)
default @NonNull StatementDefinition getPublicDefinition() {
return publicDefinition();
*
* @return raw statement argument string
* @throws VerifyException if this statement does not have an argument
+ * @deprecated Use {@link #getRawArgument()} instead.
*/
- // TODO: gradually migrate callers of this method
+ @Deprecated(forRemoval = true)
default @NonNull String coerceRawStatementArgument() {
return getRawArgument();
}
* Return the statement argument.
*
* @return statement argument, or null if this statement does not have an argument
+ * @deprecated Use {@link #argument()} instead.
*/
- // TODO: gradually migrate callers of this method
+ @Deprecated(forRemoval = true)
default @Nullable A getStatementArgument() {
return argument();
}
*
* @return raw statement argument string
* @throws VerifyException if this statement does not have an argument
+ * @deprecated Use {@link #getArgument()} instead.
*/
- // TODO: gradually migrate callers of this method
+ @Deprecated(forRemoval = true)
default @NonNull A coerceStatementArgument() {
return getArgument();
}
return verifyNotNull(getParentContext(), "Root context %s does not have a parent", this);
}
- boolean isConfiguration();
-
boolean isEnabledSemanticVersioning();
/**
- * Return a value associated with specified key within a namespace.
+ * Returns the model root for this statement.
*
- * @param type Namespace type
- * @param key Key
- * @param <K> namespace key type
- * @param <V> namespace value type
- * @param <N> namespace type
- * @param <T> key type
- * @return Value, or null if there is no element
- * @throws NamespaceNotAvailableException when the namespace is not available.
+ * @return root context of statement
*/
- <K, V, T extends K, N extends IdentifierNamespace<K, V>> @Nullable V getFromNamespace(Class<@NonNull N> type,
- T key);
-
- <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromNamespace(Class<N> type);
-
- <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromCurrentStmtCtxNamespace(Class<N> type);
-
@NonNull RootStmtContext<?, ?, ?> getRoot();
/**
return Streams.concat(declaredSubstatements().stream(), effectiveSubstatements().stream());
}
- /**
- * Builds {@link DeclaredStatement} for statement context.
- */
- D buildDeclared();
-
/**
* Builds {@link EffectiveStatement} for statement context.
*/
/*
* FIXME: YANGTOOLS-784: the next three methods are closely related to the copy process:
- * - getCopyHistory() is a brief summary of what went on
+ * - copyHistory() is a brief summary of what went on
* - getOriginalContext() points to the CopyHistory.ORIGINAL
* - getPreviousCopyCtx() points to the immediate predecessor forming a singly-linked list terminated
* at getOriginalContext()
* and hence should become arguments to that method.
*/
- /**
- * Return the executive summary of the copy process that has produced this context.
- *
- * @return A simplified summary of the copy process.
- */
- CopyHistory getCopyHistory();
-
/**
* Return the statement context of the original definition, if this statement is an instantiated copy.
*
ModelProcessingPhase getCompletedPhase();
- /**
- * Return version of root statement context.
- *
- * @return version of root statement context
- */
- @NonNull YangVersion getRootVersion();
-
/**
* An mutable view of an inference context associated with an instance of a statement.
*
return childCopyOf(stmt, type, null);
}
+ /**
+ * Create a replica of this statement as a substatement of specified {@code parent}. The replica must not be
+ * modified and acts as a source of {@link EffectiveStatement} from outside of {@code parent}'s subtree.
+ *
+ * @param parent Parent of the replica statement
+ * @return replica of this statement
+ * @throws IllegalArgumentException if this statement cannot be replicated into parent, for example because it
+ * comes from an alien implementation.
+ */
+ @NonNull Mutable<A, D, E> replicaAsChildOf(Mutable<?, ?, ?> parent);
+
@Beta
@NonNull Optional<? extends Mutable<?, ?, ?>> copyAsChildOf(Mutable<?, ?, ?> parent, CopyType type,
@Nullable QNameModule targetModule);
void setIsSupportedToBuildEffective(boolean isSupportedToBuild);
}
-
- /**
- * Search of any child statement context of specified type and return its argument. If such a statement exists, it
- * is assumed to have the right argument. Users should be careful to use this method for statements which have
- * cardinality {@code 0..1}, otherwise this method can return any one of the statement's argument.
- *
- * <p>
- * The default implementation defers to
- * {@link StmtContextDefaults#findSubstatementArgument(StmtContext, Class)}, subclasses are expected to provide
- * optimized implementation if possible.
- *
- * @param <X> Substatement argument type
- * @param <Z> Substatement effective statement representation
- * @param type Effective statement representation being look up
- * @return {@link Optional#empty()} if no statement exists, otherwise the argument value
- */
- default <X, Z extends EffectiveStatement<X, ?>> @NonNull Optional<X> findSubstatementArgument(
- final @NonNull Class<Z> type) {
- return StmtContextDefaults.findSubstatementArgument(this, type);
- }
-
- /**
- * Check if there is any child statement context of specified type.
- *
- * <p>
- * The default implementation defers to {@link StmtContextDefaults#hasSubstatement(StmtContext, Class)},
- * subclasses are expected to provide optimized implementation if possible.
- *
- * @param type Effective statement representation being look up
- * @return True if such a child statement exists, false otherwise
- */
- default boolean hasSubstatement(final @NonNull Class<? extends EffectiveStatement<?, ?>> type) {
- return StmtContextDefaults.hasSubstatement(this, type);
- }
}