X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-spi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fspi%2Fmeta%2FStmtContext.java;h=dcbafed8370a66040a122221326d568ceb72555d;hb=e763e5227cf4dfd535d2fbfc92d8f289ef38a799;hp=e96b8530c3da9cf38f3040ba49a61b317f3f752a;hpb=5db72610e7358baa1f5c9dd85abc9e93f3c8b020;p=yangtools.git diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java index e96b8530c3..dcbafed837 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java @@ -14,7 +14,6 @@ import com.google.common.base.VerifyException; 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; @@ -37,7 +36,7 @@ import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReferenc * @param Effective Statement representation */ public interface StmtContext, E extends EffectiveStatement> - extends BoundStmtCtx { + extends NamespaceStmtCtx, BoundStmtCtxCompat { @Deprecated(forRemoval = true) default @NonNull StatementDefinition getPublicDefinition() { return publicDefinition(); @@ -69,8 +68,9 @@ public interface StmtContext, E extends Effect * * @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(); } @@ -79,8 +79,9 @@ public interface StmtContext, E extends Effect * 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(); } @@ -90,8 +91,9 @@ public interface StmtContext, E extends Effect * * @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(); } @@ -113,29 +115,13 @@ public interface StmtContext, E extends Effect 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 namespace key type - * @param namespace value type - * @param namespace type - * @param key type - * @return Value, or null if there is no element - * @throws NamespaceNotAvailableException when the namespace is not available. + * @return root context of statement */ - > @Nullable V getFromNamespace(Class<@NonNull N> type, - T key); - - > Map getAllFromNamespace(Class type); - - > Map getAllFromCurrentStmtCtxNamespace(Class type); - @NonNull RootStmtContext getRoot(); /** @@ -161,11 +147,6 @@ public interface StmtContext, E extends Effect return Streams.concat(declaredSubstatements().stream(), effectiveSubstatements().stream()); } - /** - * Builds {@link DeclaredStatement} for statement context. - */ - D buildDeclared(); - /** * Builds {@link EffectiveStatement} for statement context. */ @@ -179,7 +160,7 @@ public interface StmtContext, E extends Effect /* * 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() @@ -190,13 +171,6 @@ public interface StmtContext, E extends Effect * 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. * @@ -214,13 +188,6 @@ public interface StmtContext, E extends Effect 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. * @@ -289,6 +256,17 @@ public interface StmtContext, E extends Effect 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 replicaAsChildOf(Mutable parent); + @Beta @NonNull Optional> copyAsChildOf(Mutable parent, CopyType type, @Nullable QNameModule targetModule); @@ -376,38 +354,4 @@ public interface StmtContext, E extends Effect 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. - * - *

- * The default implementation defers to - * {@link StmtContextDefaults#findSubstatementArgument(StmtContext, Class)}, subclasses are expected to provide - * optimized implementation if possible. - * - * @param Substatement argument type - * @param 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 > @NonNull Optional findSubstatementArgument( - final @NonNull Class type) { - return StmtContextDefaults.findSubstatementArgument(this, type); - } - - /** - * Check if there is any child statement context of specified type. - * - *

- * 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> type) { - return StmtContextDefaults.hasSubstatement(this, type); - } }