Bug 2366 - Effective statments impl merge, retest & bugfix
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / StmtContext.java
index 43e2014e32164c5a48bdb4b24e3009eae6646d16..d46e2716a73a4027fed0685c8425fc31187887d5 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.parser.spi.meta;
 
 import java.util.List;
-
 import java.util.Map;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
@@ -23,59 +22,104 @@ 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;
 
+public interface StmtContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> {
+
+    @Nonnull
+    StatementSource getStatementSource();
 
-public interface StmtContext<A,D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> {
+    @Nonnull
+    StatementSourceReference getStatementSourceReference();
 
-    @Nonnull StatementSource getStatementSource();
+    @Nonnull
+    StatementDefinition getPublicDefinition();
 
-    @Nonnull StatementSourceReference getStatementSourceReference();
+    @Nullable
+    StmtContext<?, ?, ?> getParentContext();
 
-    @Nonnull StatementDefinition getPublicDefinition();
+    @Nullable
+    String rawStatementArgument();
 
-    @Nullable StmtContext<?,?,?> getParentContext();
+    @Nullable
+    A getStatementArgument();
 
-    @Nullable String rawStatementArgument();
+    @Nullable
+    List<Object> getArgumentsFromRoot();
 
-    @Nullable A getStatementArgument();
+    List<StmtContext<?,?,?>> getStmtContextsFromRoot();
 
-    @Nullable List<Object> getArgumentsFromRoot();
+    @Nonnull
+    <K, V, KT extends K, N extends IdentifierNamespace<K, V>> V getFromNamespace(
+            Class<N> type, KT key) throws NamespaceNotAvailableException;
 
-    //<K,VT, V extends VT,N extends IdentifierNamespace<K, V>>
-    //       <K, VT, V extends VT ,N extends IdentifierNamespace<K, V>> VT getFromNamespace(Class<N> type, K key)
-    @Nonnull <K,V,N extends IdentifierNamespace<K, V>> V getFromNamespace(Class<N> type, K key) throws NamespaceNotAvailableException;
+    <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromNamespace(
+            Class<N> type);
 
-    <K, V, N extends IdentifierNamespace<K, V>> Map<?, ?> getAllFromNamespace(Class<N> type);
+    <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromCurrentStmtCtxNamespace(Class<N> type);
 
-    @Nonnull StmtContext<?,?,?> getRoot();
+    @Nonnull
+    StmtContext<?, ?, ?> getRoot();
 
-    @Nonnull Collection<StatementContextBase<?,?,?>> declaredSubstatements();
+    @Nonnull
+    Collection<StatementContextBase<?, ?, ?>> declaredSubstatements();
 
-    public Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements();
+    Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements();
 
     D buildDeclared();
 
     E buildEffective();
 
-    public StatementContextBase<?, ?, ?>  createCopy(QNameModule newQNameModule,StatementContextBase<?, ?, ?> newParent) throws SourceException;
+    boolean isSupportedToBuildEffective();
+
+    void setIsSupportedToBuildEffective(boolean isSupportedToBuild);
+
+    Collection<StatementContextBase<?, ?, ?>> getEffectOfStatement();
+
+    void addAsEffectOfStatement(StatementContextBase<?, ?, ?> ctx);
+
+    StatementContextBase<?, ?, ?> createCopy(
+            StatementContextBase<?, ?, ?> newParent, TypeOfCopy typeOfCopy)
+            throws SourceException;
+
+    StatementContextBase<?, ?, ?> createCopy(QNameModule newQNameModule,
+            StatementContextBase<?, ?, ?> newParent, TypeOfCopy typeOfCopy)
+            throws SourceException;
+
+    enum TypeOfCopy {
+        ORIGINAL, ADDED_BY_USES, ADDED_BY_AUGMENTATION, ADDED_BY_USES_AUGMENTATION
+    }
+
+    TypeOfCopy getTypeOfCopy();
+
+    void setTypeOfCopy(TypeOfCopy typeOfCopy);
+
+    StatementContextBase<?, ?, ?> getOriginalCtx();
+
+    void setOriginalCtx(StatementContextBase<?, ?, ?> originalCtx);
+
+    boolean isRootContext();
 
-    interface Mutable<A,D extends DeclaredStatement<A>,E extends EffectiveStatement<A, D>> extends StmtContext<A,D,E> {
+    void setCompletedPhase(ModelProcessingPhase completedPhase);
+
+    ModelProcessingPhase getCompletedPhase();
+
+    interface Mutable<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
+            extends StmtContext<A, D, E> {
 
         @Override
-        StmtContext.Mutable<?,?,?> getParentContext();
+        StmtContext.Mutable<?, ?, ?> getParentContext();
 
-        //<K,V,VT extends V,N extends IdentifierNamespace<K, V>> void addToNs(Class<N> type, K key, VT value)
-        <K,V,VT extends V,N extends IdentifierNamespace<K, V>> void addToNs(Class<N> type, K key, VT value) throws NamespaceNotAvailableException;
+        <K, V, KT extends K, VT extends V, N extends IdentifierNamespace<K, V>> void addToNs(
+                Class<N> type, KT key, VT value)
+                throws NamespaceNotAvailableException;
 
         @Override
-        StmtContext.Mutable<?,?,?> getRoot();
+        StmtContext.Mutable<?, ?, ?> getRoot();
 
         ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
 
-        <K,KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(Class<N> namespace, KT key,
-                StmtContext<?, ?, ?> stmt);
+        <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(
+                Class<N> namespace, KT key, StmtContext<?, ?, ?> stmt);
 
     }
 
-
-
 }