Introduce NamespaceStmtCtx
[yangtools.git] / yang / yang-parser-spi / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / EffectiveStmtCtx.java
index e259f38ac31c50f74729301fa7098b97c8303482..5e52a77f29810535d47315f7aa7e08243479b651 100644 (file)
@@ -11,22 +11,19 @@ import static com.google.common.base.Verify.verifyNotNull;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.VerifyException;
-import java.util.Map;
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.yang.common.YangVersion;
 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;
 
 /**
  * Effective view of a {@link StmtContext} for the purposes of creating an {@link EffectiveStatement}.
  */
 @Beta
-public interface EffectiveStmtCtx extends CommonStmtCtx, Immutable {
+public interface EffectiveStmtCtx extends CommonStmtCtx, StmtContextCompat, Immutable {
     /**
      * Return parent of this context, if there is one. All statements except for top-level source statements, such as
      * {@code module} and {@code submodule}.
@@ -54,6 +51,14 @@ public interface EffectiveStmtCtx extends CommonStmtCtx, Immutable {
         // FIXME: 7.0.0: this should be Optional<Boolean>
         boolean effectiveConfig();
 
+        /**
+         * Return the {@link SchemaPath} of this statement. Not all statements have a SchemaPath, in which case
+         * {@link Optional#empty()} is returned.
+         *
+         * @return Optional SchemaPath
+         * @deprecated Use of SchemaPath in the context of effective statements is going away. Consider not providing
+         *             this information, if your users can exist without it.
+         */
         // FIXME: 7.0.0: this needs to be a tri-state present/absent/disabled
         @Deprecated
         @NonNull Optional<SchemaPath> schemaPath();
@@ -72,29 +77,14 @@ public interface EffectiveStmtCtx extends CommonStmtCtx, Immutable {
      * @param <D> Class representing declared version of this statement
      */
     @Beta
-    interface Current<A, D extends DeclaredStatement<A>> extends Parent {
+    interface Current<A, D extends DeclaredStatement<A>> extends Parent, BoundStmtCtx<A>, NamespaceStmtCtx {
 
         @NonNull CommonStmtCtx root();
 
-        @NonNull CopyHistory history();
-
         @NonNull D declared();
 
-        <K, V, T extends K, N extends IdentifierNamespace<K, V>> @Nullable V getFromNamespace(Class<@NonNull N> type,
-            T key);
-
-        <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromCurrentStmtCtxNamespace(Class<N> type);
-
-        @Nullable A argument();
-
-        default @NonNull A coerceArgument() {
-            return verifyNotNull(argument(), "Attempted to use non-existent argument");
-        }
-
         @Nullable EffectiveStatement<?, ?> original();
 
-        @NonNull YangVersion yangVersion();
-
         /**
          * Summon the <a href="https://en.wikipedia.org/wiki/Rabbit_of_Caerbannog">Rabbit of Caerbannog</a>.
          *