Fix StmtContext nullness confusion 37/87637/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 12 Feb 2020 16:15:02 +0000 (17:15 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 12 Feb 2020 17:25:53 +0000 (18:25 +0100)
The API contract states that null is a valid return, but returned
value is tagged with @NonNull -- throwing off static analysis quite
a bit. Correct the annotation, making life easier.

Change-Id: I4c9cf79e99c6f3d59d5adfaadbbd8ce855a2c47d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/module/ModuleStmtContext.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java

index 0e7e70b3a71cd8fb8d6af304cb40b108a8f6adf7..64de853870dc31da97a10b1a4bd37e0add3a02b7 100644 (file)
@@ -153,7 +153,7 @@ final class ModuleStmtContext extends ForwardingObject
     }
 
     @Override
-    public <K, V, T extends K, N extends IdentifierNamespace<K, V>> @NonNull V getFromNamespace(final Class<N> type,
+    public <K, V, T extends K, N extends IdentifierNamespace<K, V>> V getFromNamespace(final Class<N> type,
             final T key) {
         return delegate.getFromNamespace(type, key);
     }
index 91eb89a005770f9493c7029a3fa7b1e6be4fb2b2..fc10ce193fc6920ff35548230182767cf880106b 100644 (file)
@@ -132,7 +132,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);