Deprecate StmtContext.getSchemaPath()
[yangtools.git] / yang / yang-parser-spi / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / StmtContext.java
index 9f81a5147f560e1fffe46d2bc0f6109ac307fa2b..c264043d5a0a46aeae51b4d69891d4819371f12c 100644 (file)
@@ -108,12 +108,24 @@ public interface StmtContext<A, D extends DeclaredStatement<A>, E extends Effect
         return verifyNotNull(getStatementArgument(), "Statement context %s does not have an argument", this);
     }
 
+    default <X, Y extends DeclaredStatement<X>> boolean producesDeclared(final Class<? super Y> type) {
+        return type.isAssignableFrom(getPublicDefinition().getDeclaredRepresentationClass());
+    }
+
+    default <X, Y extends DeclaredStatement<X>, Z extends EffectiveStatement<A, D>> boolean producesEffective(
+            final Class<? super Z> type) {
+        return type.isAssignableFrom(getPublicDefinition().getEffectiveRepresentationClass());
+    }
+
     /**
      * 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.
      */
+    @Deprecated
     @NonNull Optional<SchemaPath> getSchemaPath();
 
     boolean isConfiguration();
@@ -132,7 +144,7 @@ public interface StmtContext<A, D extends DeclaredStatement<A>, E extends Effect
      * @return Value, or null if there is no element
      * @throws NamespaceNotAvailableException when the namespace is not available.
      */
-    @NonNull <K, V, T extends K, N extends IdentifierNamespace<K, V>> V getFromNamespace(Class<N> type, T key);
+    <K, V, T extends K, N extends IdentifierNamespace<K, V>> @Nullable V getFromNamespace(Class<N> type, T key);
 
     <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromNamespace(Class<N> type);
 
@@ -377,8 +389,5 @@ public interface StmtContext<A, D extends DeclaredStatement<A>, E extends Effect
         void setRootIdentifier(SourceIdentifier identifier);
 
         void setIsSupportedToBuildEffective(boolean isSupportedToBuild);
-
-        // FIXME: this seems to be unused, but looks useful.
-        void setCompletedPhase(ModelProcessingPhase completedPhase);
     }
 }