Bug 2366 - Effective statement implementation
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / StmtContext.java
index 124d6bf9e18772f52b02e1ea3ba133e5b60c904d..5b85dc637720f4570ca90d7bf56cf2236c788906 100644 (file)
@@ -7,6 +7,11 @@
  */
 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;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
 import java.util.Collection;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -17,48 +22,93 @@ 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>> {
 
-public interface StmtContext<A,D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> {
+    @Nonnull
+    StatementSource getStatementSource();
 
-    @Nonnull StatementSource getStatementSource();
+    @Nonnull
+    StatementSourceReference getStatementSourceReference();
 
-    @Nonnull StatementSourceReference getStatementSourceReference();
+    @Nonnull
+    StatementDefinition getPublicDefinition();
 
-    @Nonnull StatementDefinition getPublicDefinition();
+    @Nullable
+    StmtContext<?, ?, ?> getParentContext();
 
-    @Nullable StmtContext<?,?,?> getParentContext();
+    @Nullable
+    String rawStatementArgument();
 
-    @Nullable String rawStatementArgument();
+    @Nullable
+    A getStatementArgument();
 
-    @Nullable A getStatementArgument();
+    @Nullable
+    List<Object> getArgumentsFromRoot();
 
-    @Nonnull <K,VT, V extends VT,N extends IdentifierNamespace<K, V>> VT getFromNamespace(Class<N> type, K 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;
 
-    @Nonnull StmtContext<?,?,?> getRoot();
+    <K, V, N extends IdentifierNamespace<K, V>> Map<?, ?> getAllFromNamespace(
+            Class<N> type);
 
-    @Nonnull Collection<? extends StmtContext<?,?,?>> declaredSubstatements();
+    @Nonnull
+    StmtContext<?, ?, ?> getRoot();
+
+    @Nonnull
+    Collection<StatementContextBase<?, ?, ?>> declaredSubstatements();
+
+    public Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements();
 
     D buildDeclared();
 
     E buildEffective();
 
-    interface Mutable<A,D extends DeclaredStatement<A>,E extends EffectiveStatement<A, D>> extends StmtContext<A,D,E> {
+    public StatementContextBase<?, ?, ?> createCopy(QNameModule newQNameModule,
+            StatementContextBase<?, ?, ?> newParent, TypeOfCopy typeOfCopy)
+            throws SourceException;
+
+    public static enum TypeOfCopy {
+        ORIGINAL, ADDED_BY_USES, ADDED_BY_AUGMENTATION
+    }
+
+    public TypeOfCopy getTypeOfCopy();
+
+    public void setTypeOfCopy(TypeOfCopy typeOfCopy);
+
+    public StatementContextBase<?, ?, ?> getOriginalCtx();
+
+    public void setOriginalCtx(StatementContextBase<?, ?, ?> originalCtx);
+
+    public boolean isRootContext();
+
+    public void setCompletedPhase(ModelProcessingPhase completedPhase);
+
+    public 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) throws NamespaceNotAvailableException;
+        // <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;
 
         @Override
-        StmtContext.Mutable<?,?,?> getRoot();
+        StmtContext.Mutable<?, ?, ?> getRoot();
 
         ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
 
-        <K,KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(Class<N> namepsace, KT key,
-                StmtContext<?, ?, ?> stmt);
+        <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(
+                Class<N> namespace, KT key, StmtContext<?, ?, ?> stmt);
 
     }
 
-
-
 }