BUG-865: add proper nullness annotations 54/42854/2
authorRobert Varga <rovarga@cisco.com>
Sun, 31 Jul 2016 14:45:47 +0000 (16:45 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Mon, 1 Aug 2016 09:19:12 +0000 (09:19 +0000)
This fixes the mistake of making DocumentedNode.getStatus()
nullable and adds explicit annotations to DocumentedNode,
SchemaNode and UsesNode.

Change-Id: Ibc773feeca2a3f61d8a74c5b6cbc3028a2f4d260
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DocumentedNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/UsesNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/BitsTypeDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/EnumTypeDefinition.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitsSpecificationEffectiveStatementImpl.java

index e4a87f3a4068cb66e9c94d03ee2db6846c897c9f..876645f9654b872044f17467430e41fb483bb5c1 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.model.api;
 
 import com.google.common.collect.ImmutableList;
 import java.util.List;
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 /**
@@ -24,7 +25,7 @@ public interface DocumentedNode {
      * @return string with textual description the node which represents the
      *         argument of the YANG <code>description</code> substatement
      */
-    String getDescription();
+    @Nullable String getDescription();
 
     /**
      * Returns reference of the instance of the type <code>SchemaNode</code>
@@ -36,7 +37,7 @@ public interface DocumentedNode {
      *         represents the argument of the YANG <code>reference</code>
      *         substatement
      */
-    String getReference();
+    @Nullable String getReference();
 
     /**
      * Returns status of the instance of the type <code>SchemaNode</code>
@@ -44,14 +45,14 @@ public interface DocumentedNode {
      * @return status of this node which represents the argument of the YANG
      *         <code>status</code> substatement
      */
-    @Nullable Status getStatus();
+    @Nonnull Status getStatus();
 
     /**
      * Returns unknown schema nodes which belongs to this instance.
      *
      * @return list of unknown schema nodes defined under this node.
      */
-    default List<UnknownSchemaNode> getUnknownSchemaNodes() {
+    default @Nonnull List<UnknownSchemaNode> getUnknownSchemaNodes() {
         return ImmutableList.of();
     }
 }
index d86f1d777855611cbbad576c333cffb996fd052c..ea4f80d02dca913c25fd82ea9beda2727bf2a8a6 100644 (file)
@@ -7,19 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.model.api;
 
+import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.common.QName;
 
 /**
  * SchemaNode represents a node in schema tree.
  */
 public interface SchemaNode extends DocumentedNode {
-
     /**
      * Returns QName of the instance of the type <code>SchemaNode</code>.
      *
      * @return QName with the name of the schema node
      */
-    QName getQName();
+    @Nonnull QName getQName();
 
     /**
      * Returns the schema path of the instance of the type
@@ -27,5 +27,5 @@ public interface SchemaNode extends DocumentedNode {
      *
      * @return schema path of the schema node
      */
-    SchemaPath getPath();
+    @Nonnull SchemaPath getPath();
 }
index eb8b27a4317c5d0c54a1dfe4cccf5df9413857ba..5979333156f8a17e1dbcc54391a6b57c84b33812 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.model.api;
 import com.google.common.base.Optional;
 import java.util.Map;
 import java.util.Set;
+import javax.annotation.Nonnull;
 
 /**
  * Contains the methods for getting data and checking properties of the YANG
@@ -23,7 +24,7 @@ public interface UsesNode extends DocumentedNode {
      *
      * @return schema path to 'grouping' on which this 'uses' statement points
      */
-    SchemaPath getGroupingPath();
+    @Nonnull SchemaPath getGroupingPath();
 
     /**
      *
@@ -31,7 +32,7 @@ public interface UsesNode extends DocumentedNode {
      *
      * @return Set of augment statements defined under this uses node
      */
-    Set<AugmentationSchema> getAugmentations();
+    @Nonnull Set<AugmentationSchema> getAugmentations();
 
     /**
      * Returns <code>true</code> if the data node was added by augmentation,
@@ -58,7 +59,7 @@ public interface UsesNode extends DocumentedNode {
      * @return Map, where key is schema path of refined node and value is
      *         refined node
      */
-    Map<SchemaPath, SchemaNode> getRefines();
+    @Nonnull Map<SchemaPath, SchemaNode> getRefines();
 
     /**
      * Returns when statement
@@ -70,7 +71,7 @@ public interface UsesNode extends DocumentedNode {
      *
      * @return Optional of XPath condition
      */
-    default Optional<RevisionAwareXPath> getWhenCondition() {
+    default @Nonnull Optional<RevisionAwareXPath> getWhenCondition() {
         return Optional.absent();
     }
 }
index f0a27f5da266a86e3a5ea76b2bfd37e80c8c0b89..7d13921ffe0228d30b87732f602517cf13d53fcc 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.yangtools.yang.model.api.type;
 
 import java.util.List;
-
+import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
@@ -18,14 +18,13 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
  *
  */
 public interface BitsTypeDefinition extends TypeDefinition<BitsTypeDefinition> {
-
     /**
      * Returns all bit values.
      *
      * @return list of <code>Bit</code> type instastances with data about all
      *         individual bits of <code>bits</code> YANG built-in type
      */
-    List<Bit> getBits();
+    @Nonnull List<Bit> getBits();
 
     /**
      *
@@ -46,6 +45,6 @@ public interface BitsTypeDefinition extends TypeDefinition<BitsTypeDefinition> {
          *
          * @return string with the name of the concrete bit
          */
-        String getName();
+        @Nonnull String getName();
     }
 }
index 15d9cfcb661ea0842a0c2d845ec9de9622d18568..eaa3fa6c98d9aaea297d61bc6f1120dee845dc99 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.model.api.type;
 
 import java.util.List;
+import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.model.api.DocumentedNode;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
@@ -18,7 +19,6 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
  *
  */
 public interface EnumTypeDefinition extends TypeDefinition<EnumTypeDefinition> {
-
     /**
      * Returns all enumeration values.
      *
@@ -26,7 +26,7 @@ public interface EnumTypeDefinition extends TypeDefinition<EnumTypeDefinition> {
      *         data about all individual enumeration pairs of
      *         <code>enumeration</code> YANG built-in type
      */
-    List<EnumPair> getValues();
+    @Nonnull List<EnumPair> getValues();
 
     /**
      *
index bfeba648a9cc9dab13cc1900acdb251b99a71105..67d0d5a337a3041f94138a4db05a1650b9005c4d 100644 (file)
@@ -33,7 +33,7 @@ public class BitEffectiveStatementImpl extends DeclaredEffectiveStatementBase<QN
     private Long position;
     private String description;
     private String reference;
-    private Status status;
+    private Status status = Status.CURRENT;
     private final List<UnknownSchemaNode> unknownSchemaNodes;
 
     public BitEffectiveStatementImpl(final StmtContext<QName, BitStatement, ?> ctx) {
index 03d85d0c2886646afdfca348565158428c4dd802..582695b8ec5ed0cd650ce6d948e7cbded3e525c9 100644 (file)
@@ -45,14 +45,9 @@ public final class BitsSpecificationEffectiveStatementImpl extends
                             "Bit %s must have a position statement", b);
                     }
 
-                    final BitBuilder bitBuilder = BitBuilder.create(b.getPath(), newPos)
-                            .setDescription(b.getDescription()).setReference(b.getReference())
-                            .setUnknownSchemaNodes(b.getUnknownSchemaNodes());
-                    if (b.getStatus() != null) {
-                        bitBuilder.setStatus(b.getStatus());
-                    }
-
-                    b = bitBuilder.build();
+                    b = BitBuilder.create(b.getPath(), newPos).setDescription(b.getDescription())
+                            .setReference(b.getReference()).setStatus(b.getStatus())
+                            .setUnknownSchemaNodes(b.getUnknownSchemaNodes()).build();
                 }
 
                 SourceException.throwIf(b.getPosition() < 0L && b.getPosition() > 4294967295L,