Enforce namespace listener compatibility
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / StmtContext.java
index 62b48676e5afe20562952c1a1940ecf871e58fc8..52bd1aa1c965af39a60cb069cbbea0c9203b9725 100644 (file)
@@ -13,6 +13,8 @@ import java.util.Map;
 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;
@@ -34,9 +36,15 @@ public interface StmtContext<A, D extends DeclaredStatement<A>, E extends Effect
     @Nonnull
     StatementDefinition getPublicDefinition();
 
+    /**
+     * @return context of parent of statement
+     */
     @Nullable
     StmtContext<?, ?, ?> getParentContext();
 
+    /**
+     * @return raw statement argument string
+     */
     @Nullable
     String rawStatementArgument();
 
@@ -53,6 +61,15 @@ public interface StmtContext<A, D extends DeclaredStatement<A>, E extends Effect
 
     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
@@ -84,8 +101,14 @@ public interface StmtContext<A, D extends DeclaredStatement<A>, E extends Effect
     @Nonnull
     Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements();
 
+    /**
+     * Builds {@link DeclaredStatement} for statement context.
+     */
     D buildDeclared();
 
+    /**
+     * Builds {@link EffectiveStatement} for statement context
+     */
     E buildEffective();
 
     boolean isSupportedToBuildEffective();
@@ -130,6 +153,13 @@ public interface StmtContext<A, D extends DeclaredStatement<A>, E extends Effect
 
     ModelProcessingPhase getCompletedPhase();
 
+    /**
+     * Return version of root statement context.
+     *
+     * @return version of root statement context
+     */
+    @Nonnull YangVersion getRootVersion();
+
     interface Mutable<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
             extends StmtContext<A, D, E> {
 
@@ -144,12 +174,64 @@ public interface StmtContext<A, D extends DeclaredStatement<A>, E extends Effect
         @Override
         StmtContext.Mutable<?, ?, ?> getRoot();
 
-        ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
-
+        /**
+         * 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
+         */
         <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(
                 Class<N> namespace, KT key, StmtContext<?, ?, ?> stmt);
 
         void setSupportedByFeatures(boolean isSupported);
-    }
 
+        /**
+         * 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);
+
+        /**
+         * Set identifier of current root context.
+         *
+         * @param identifier
+         *            of current root context
+         */
+        void setRootIdentifier(ModuleIdentifier identifier);
+    }
 }