X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fspi%2Fmeta%2FStmtContext.java;h=ac2d6a914d671982c3b48136b41236cd248b67ae;hb=104b5d943c96fcdd30a5cf7ea3d79e6a55082c60;hp=124d6bf9e18772f52b02e1ea3ba133e5b60c904d;hpb=ca477d3ffa9bb3627cbefc9505f9a858d25dd673;p=yangtools.git
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java
index 124d6bf9e1..ac2d6a914d 100644
--- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java
+++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java
@@ -8,57 +8,228 @@
package org.opendaylight.yangtools.yang.parser.spi.meta;
import java.util.Collection;
+import java.util.Map;
+import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.common.YangVersion;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
+
+public interface StmtContext, E extends EffectiveStatement> {
+
+ @Nonnull
+ StatementSource getStatementSource();
+
+ @Nonnull
+ StatementSourceReference getStatementSourceReference();
+
+ @Nonnull
+ StatementDefinition getPublicDefinition();
+
+ /**
+ * Return the parent statement context, or null if this is the root statement.
+ *
+ * @return context of parent of statement, or null if this is the root statement.
+ */
+ @Nullable
+ StmtContext, ?, ?> getParentContext();
+
+ /**
+ * @return raw statement argument string
+ */
+ @Nullable
+ String rawStatementArgument();
+
+ @Nullable
+ A getStatementArgument();
+
+ /**
+ * Return the {@link SchemaPath} of this statement. Not all statements have a SchemaPath, in which case
+ * {@link Optional#empty()} is returned.
+ *
+ * @return Optional SchemaPath
+ */
+ @Nonnull Optional getSchemaPath();
+
+ boolean isConfiguration();
+
+ /**
+ * Checks whether this statement is placed within a 'yang-data' extension statement.
+ * Some YANG statements are constrained when used within a 'yang-data' statement.
+ * See the following link for more information - https://tools.ietf.org/html/rfc8040#section-8
+ *
+ * @return true if it is placed within a 'yang-data' extension statement, otherwise false
+ */
+ boolean isInYangDataExtensionBody();
+
+ boolean isEnabledSemanticVersioning();
+
+ @Nonnull
+ > V getFromNamespace(
+ Class type, KT key) throws NamespaceNotAvailableException;
+
+ > Map getAllFromNamespace(
+ Class type);
+
+ > Map getAllFromCurrentStmtCtxNamespace(Class type);
+
+ @Nonnull
+ StmtContext, ?, ?> getRoot();
+
+ /**
+ * Return declared substatements. These are the statements which are explicitly written in the source model.
+ *
+ * @return Collection of declared substatements
+ */
+ @Nonnull
+ Collection extends StmtContext, ?, ?>> declaredSubstatements();
+
+ /**
+ * Return effective substatements. These are the statements which are added as this statement's substatements
+ * complete their effective model phase.
+ *
+ * @return Collection of declared substatements
+ */
+ @Nonnull
+ Collection extends StmtContext, ?, ?>> effectiveSubstatements();
+
+ /**
+ * Builds {@link DeclaredStatement} for statement context.
+ */
+ D buildDeclared();
+ /**
+ * Builds {@link EffectiveStatement} for statement context
+ */
+ E buildEffective();
-public interface StmtContext, E extends EffectiveStatement> {
-
- @Nonnull StatementSource getStatementSource();
-
- @Nonnull StatementSourceReference getStatementSourceReference();
-
- @Nonnull StatementDefinition getPublicDefinition();
+ boolean isSupportedToBuildEffective();
- @Nullable StmtContext,?,?> getParentContext();
+ Collection extends StmtContext, ?, ?>> getEffectOfStatement();
- @Nullable String rawStatementArgument();
+ /**
+ * @return copy of this considering {@link CopyType} (augment, uses)
+ *
+ * @throws org.opendaylight.yangtools.yang.parser.spi.source.SourceException instance of SourceException
+ */
+ Mutable createCopy(StatementContextBase, ?, ?> newParent, CopyType typeOfCopy);
- @Nullable A getStatementArgument();
+ /**
+ * @return copy of this considering {@link CopyType} (augment, uses)
+ *
+ * @throws org.opendaylight.yangtools.yang.parser.spi.source.SourceException instance of SourceException
+ */
+ Mutable createCopy(QNameModule newQNameModule, StatementContextBase, ?, ?> newParent,
+ CopyType typeOfCopy);
- @Nonnull > VT getFromNamespace(Class type, K key) throws NamespaceNotAvailableException;
+ CopyHistory getCopyHistory();
- @Nonnull StmtContext,?,?> getRoot();
+ boolean isSupportedByFeatures();
- @Nonnull Collection extends StmtContext,?,?>> declaredSubstatements();
+ Optional> getOriginalCtx();
- D buildDeclared();
+ ModelProcessingPhase getCompletedPhase();
- E buildEffective();
+ /**
+ * Return version of root statement context.
+ *
+ * @return version of root statement context
+ */
+ @Nonnull YangVersion getRootVersion();
- interface Mutable,E extends EffectiveStatement> extends StmtContext {
+ interface Mutable, E extends EffectiveStatement>
+ extends StmtContext {
@Override
- StmtContext.Mutable,?,?> getParentContext();
+ Mutable, ?, ?> getParentContext();
- > void addToNs(Class type, K key, VT value) throws NamespaceNotAvailableException;
+ > void addToNs(Class type, KT key,
+ VT value) throws NamespaceNotAvailableException;
+ @Nonnull
@Override
- StmtContext.Mutable,?,?> getRoot();
-
- ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
-
- > void addContext(Class namepsace, KT key,
+ Mutable, ?, ?> getRoot();
+
+ @Nonnull
+ Collection extends Mutable, ?, ?>> mutableDeclaredSubstatements();
+
+ @Nonnull
+ Collection extends Mutable, ?, ?>> mutableEffectiveSubstatements();
+
+ /**
+ * Create a new inference action to be executed during specified phase. The action cannot be cancelled
+ * and will be executed even if its definition remains incomplete.
+ *
+ * @param phase Target phase in which the action will resolved.
+ * @return A new action builder.
+ * @throws NullPointerException if the specified phase is null
+ */
+ @Nonnull ModelActionBuilder newInferenceAction(@Nonnull ModelProcessingPhase phase);
+
+ /**
+ * adds statement to namespace map with the key
+ *
+ * @param namespace
+ * {@link StatementNamespace} child that determines namespace to be added to
+ * @param key
+ * of type according to namespace class specification
+ * @param stmt
+ * to be added to namespace map
+ */
+ > void addContext(Class namespace, KT key,
StmtContext, ?, ?> stmt);
+ /**
+ * Set version of root statement context.
+ *
+ * @param version
+ * of root statement context
+ */
+ void setRootVersion(YangVersion version);
+
+ /**
+ * Add mutable statement to seal. Each mutable statement must be sealed
+ * as the last step of statement parser processing.
+ *
+ * @param mutableStatement
+ * mutable statement which should be sealed
+ */
+ void addMutableStmtToSeal(MutableStatement mutableStatement);
+
+ /**
+ * Add required module. Based on these dependencies are collected
+ * required sources from library sources.
+ *
+ * @param dependency
+ * ModuleIdentifier of module required by current root
+ * context
+ */
+ void addRequiredModule(ModuleIdentifier dependency);
+
+ void addAsEffectOfStatement(StmtContext, ?, ?> ctx);
+
+ void addAsEffectOfStatement(Collection extends StmtContext, ?, ?>> ctxs);
+
+ /**
+ * Set identifier of current root context.
+ *
+ * @param identifier
+ * of current root context
+ */
+ void setRootIdentifier(ModuleIdentifier identifier);
+
+ void setIsSupportedToBuildEffective(boolean isSupportedToBuild);
+
+ // FIXME: this seems to be unused, but looks useful.
+ void setCompletedPhase(ModelProcessingPhase completedPhase);
}
-
-
-
}