Add nullness annotations 44/87044/1
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 19 Jan 2020 11:08:23 +0000 (12:08 +0100)
committerRobert Varga <nite@hq.sk>
Sun, 19 Jan 2020 23:05:32 +0000 (23:05 +0000)
Not promising proper nullness leads to warnings downstream, do the
right thing and say when we promise non-nulls.

Change-Id: Ib34d57b45905d6164456ef0605ce6cca65f9de4f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3fa1fbe01d3f981f746622a309e159a9632ad58a)

yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/DataTreeCandidate.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/DataTreeFactory.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/DataTreeSnapshot.java

index 063302c3c6ad1770aba2ad249b3b2f0a54bbdffe..593e3a6b7037764e5c1f607478b18cfbf7fa9bc1 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.data.api.schema.tree;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 /**
@@ -17,6 +19,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
  * is limited to nodes which were affected by the modification from which
  * this instance originated.
  */
+@NonNullByDefault
 public interface DataTreeCandidate {
     /**
      * Get the candidate tree root node.
@@ -48,5 +51,5 @@ public interface DataTreeCandidate {
      * equals implementation must result in identity comparison.
      */
     @Override
-    boolean equals(Object obj);
+    boolean equals(@Nullable Object obj);
 }
index f7becfe3f88c98bca6cddd2d30e3a3827cba1fd2..3f92744149e336579854510e150a6dadcf30b641 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.yangtools.yang.data.api.schema.tree;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
@@ -30,7 +31,7 @@ public interface DataTreeFactory {
      * @return A data tree instance.
      * @throws NullPointerException if treeConfig is null
      */
-    DataTree create(DataTreeConfiguration treeConfig);
+    @NonNull DataTree create(DataTreeConfiguration treeConfig);
 
     /**
      * Create a new data tree based on specified configuration, with a root node derived from the schema context lookup
@@ -44,7 +45,7 @@ public interface DataTreeFactory {
      * @throws IllegalArgumentException if tree configuration does not match the SchemaContext, for example by root path
      *                                  referring to a node which does not exist in the SchemaContext
      */
-    DataTree create(DataTreeConfiguration treeConfig, SchemaContext initialSchemaContext);
+    @NonNull DataTree create(DataTreeConfiguration treeConfig, SchemaContext initialSchemaContext);
 
     /**
      * Create a new data tree based on specified configuration, with the specified node.
@@ -56,6 +57,6 @@ public interface DataTreeFactory {
      * @throws NullPointerException if any of the arguments are null
      * @throws IllegalArgumentException if a mismatch between the arguments is detected
      */
-    DataTree create(DataTreeConfiguration treeConfig, SchemaContext initialSchemaContext,
+    @NonNull DataTree create(DataTreeConfiguration treeConfig, SchemaContext initialSchemaContext,
             NormalizedNodeContainer<?, ?, ?> initialRoot) throws DataValidationFailedException;
 }
index e8c3141946cf889c382f4e450b44326b84e4ea6c..d7e855e7bd3d0199b45676cef0fab331c871d8ab 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.data.api.schema.tree;
 
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
@@ -31,5 +32,5 @@ public interface DataTreeSnapshot extends SchemaContextProvider {
      *
      * @return A new data tree modification
      */
-    DataTreeModification newModification();
+    @NonNull DataTreeModification newModification();
 }