Propagate @NonNull collection annotations 75/93875/10
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 18 Nov 2020 11:24:49 +0000 (12:24 +0100)
committerRobert Varga <nite@hq.sk>
Wed, 18 Nov 2020 18:50:06 +0000 (18:50 +0000)
We do not allow nulls in our collections. Add the appropriate
annotation to trim down downstream false positives.

Change-Id: Iceaf2bdd6a82b0ad73035ab86d06f283e46c42c5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
26 files changed:
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ActionNodeContainer.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/AugmentationTarget.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ChoiceSchemaNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DataNodeContainer.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DeviateDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/Deviation.java
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/IdentitySchemaNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/LeafListSchemaNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ListSchemaNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ModuleLike.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/MustConstraintAware.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/NotificationNodeContainer.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/OperationDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaContext.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/meta/EffectiveStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/RangeConstraint.java
yang/yang-model-util/src/main/java/module-info.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/AbstractSchemaContext.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/FilteringSchemaContextProxy.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/SimpleSchemaContext.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/ResolvedRangeConstraint.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveStatement.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/EffectiveStatementMixins.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/deviate/DeviateEffectiveStatementImpl.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/TestUtils.java

index 420d99f3db94a7213ca7e8ccf97c5f7279eb4bd9..c258c38d75ef3bc46d7495ee3a4cb786f7b3beb8 100644 (file)
@@ -25,7 +25,7 @@ public interface ActionNodeContainer {
      *
      * @return set of action nodes
      */
-    @NonNull Collection<? extends ActionDefinition> getActions();
+    @NonNull Collection<? extends @NonNull ActionDefinition> getActions();
 
     /**
      * Find an action based on its QName. Default implementation searches the set returned by {@link #getActions()}.
index dbf8e46f5deb0f06abb1162aa35eff9204b39413..22276991f7c8a2627b487b71304ae1e5f07e7f74 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.model.api;
 
 import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
 
 /**
  * Interface for all nodes which are possible targets of augmentation. The
@@ -20,5 +21,5 @@ public interface AugmentationTarget {
      *
      * @return set of augmentations targeting this element.
      */
-    Collection<? extends AugmentationSchemaNode> getAvailableAugmentations();
+    @NonNull Collection<? extends @NonNull AugmentationSchemaNode> getAvailableAugmentations();
 }
index 6d7a0bd1d96682b61a480c7e2a59254691b5da72..37b4f7274e3783e045b07be5dde441b849469070 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.collect.ImmutableList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
 
@@ -30,7 +31,7 @@ public interface ChoiceSchemaNode extends DataSchemaNode, AugmentationTarget, Ma
      * @return set of ChoiceCaseNode objects defined in this node which represents set of arguments of the YANG
      *         <code>case</code> substatement of the <code>choice</code> statement.
      */
-    Collection<? extends CaseSchemaNode> getCases();
+    Collection<? extends @NonNull CaseSchemaNode> getCases();
 
     /**
      * Returns the concrete case according to specified Q name.
@@ -54,7 +55,7 @@ public interface ChoiceSchemaNode extends DataSchemaNode, AugmentationTarget, Ma
      * @throws NullPointerException if localname is null
      */
     @Beta
-    default List<? extends CaseSchemaNode> findCaseNodes(final String localname) {
+    default List<? extends @NonNull CaseSchemaNode> findCaseNodes(final String localname) {
         return getCases().stream().filter(node -> localname.equals(node.getQName().getLocalName()))
                 .collect(ImmutableList.toImmutableList());
     }
index 658d40829328d9cd2c892e1e47ff2c7e61ebbffd..9b695fe02e31014f5dc7d2a06ce0901d488424e5 100644 (file)
@@ -16,6 +16,7 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.common.QName;
 
@@ -28,7 +29,7 @@ public interface DataNodeContainer {
      *
      * @return typedef statements in lexicographical order
      */
-    Collection<? extends TypeDefinition<?>> getTypeDefinitions();
+    @NonNull Collection<? extends @NonNull TypeDefinition<?>> getTypeDefinitions();
 
     /**
      * Returns set of all child nodes defined within this DataNodeContainer. Although the return type is a collection,
@@ -41,14 +42,14 @@ public interface DataNodeContainer {
      *
      * @return child nodes in lexicographical order
      */
-    Collection<? extends DataSchemaNode> getChildNodes();
+    @NonNull Collection<? extends @NonNull DataSchemaNode> getChildNodes();
 
     /**
      * Returns set of all groupings defined within this DataNodeContainer.
      *
      * @return grouping statements in lexicographical order
      */
-    Collection<? extends GroupingDefinition> getGroupings();
+    @NonNull Collection<? extends @NonNull GroupingDefinition> getGroupings();
 
     /**
      * Returns the child node corresponding to the specified name.
@@ -114,7 +115,7 @@ public interface DataNodeContainer {
      *
      * @return Set of all uses nodes defined within this DataNodeContainer
      */
-    Collection<? extends UsesNode> getUses();
+    @NonNull Collection<? extends @NonNull UsesNode> getUses();
 
     /**
      * Returns a {@code data node} identified by a QName. This method is distinct from
index 6ba7c7c77c9ee3609c60a71e2a115e38f7ada1d3..fbe8b2674312b857e8bc4bef6926fe545de9e94e 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.model.api;
 
 import com.google.common.annotations.Beta;
 import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.stmt.DeviateEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UniqueEffectiveStatement;
 
@@ -69,7 +70,7 @@ public interface DeviateDefinition extends EffectiveStatementEquivalent<DeviateE
      *
      * @return set of the deviated must statements
      */
-    Collection<? extends MustDefinition> getDeviatedMusts();
+    Collection<? extends @NonNull MustDefinition> getDeviatedMusts();
 
     /**
      * Returns deviated type statement.
@@ -83,7 +84,7 @@ public interface DeviateDefinition extends EffectiveStatementEquivalent<DeviateE
      *
      * @return collection of the deviated unique statements
      */
-    Collection<? extends UniqueEffectiveStatement> getDeviatedUniques();
+    Collection<? extends @NonNull UniqueEffectiveStatement> getDeviatedUniques();
 
     /**
      * Returns deviated units statement.
index f9b31d3e2ce9c4ae8241486277e96b6dad2b526d..5f4b84165a485767c2a22c9c3f18309b3311378f 100644 (file)
@@ -34,5 +34,5 @@ public interface Deviation extends DocumentedNode, EffectiveStatementEquivalent<
      *
      * @return Collection of all deviate statements defined in this deviation.
      */
-    @NonNull Collection<? extends DeviateDefinition> getDeviates();
+    @NonNull Collection<? extends @NonNull DeviateDefinition> getDeviates();
 }
index 0d9b27f69ef29613961f6855feb96b374ba10e92..6fe4a293bcec65de4ee059d7d92cd998a355a27d 100644 (file)
@@ -35,7 +35,7 @@ public interface DocumentedNode {
      *
      * @return collection of unknown schema nodes defined under this node.
      */
-    default @NonNull Collection<? extends UnknownSchemaNode> getUnknownSchemaNodes() {
+    default @NonNull Collection<? extends @NonNull UnknownSchemaNode> getUnknownSchemaNodes() {
         return ImmutableList.of();
     }
 
index 8a8dd2945762317dcf500f7bc0d9f7cda359407e..3b1c5dd8d14de7c5f5b170aea2e15233659b3eef 100644 (file)
@@ -31,5 +31,5 @@ public interface IdentitySchemaNode extends SchemaNode, EffectiveStatementEquiva
      * @return set of existing identities from which the new identity is derived or an empty Set if the identity is
      *         a root identity.
      */
-    @NonNull Collection<? extends IdentitySchemaNode> getBaseIdentities();
+    @NonNull Collection<? extends @NonNull IdentitySchemaNode> getBaseIdentities();
 }
index 34828e19814b61aeef23a9f1c4cd865fe86c0c63..68a8f01ad0c7ddba67b0f607ec6d20a855cab0e4 100644 (file)
@@ -32,5 +32,5 @@ public interface LeafListSchemaNode extends TypedDataSchemaNode, MustConstraintA
      *
      * @return Ordered list of Strings which specify the default values of this leaf-list
      */
-    @NonNull Collection<? extends Object> getDefaults();
+    @NonNull Collection<? extends @NonNull Object> getDefaults();
 }
index a9627ba099704f4babef6d02f7dd8755809ae59a..848d4bada15e679199e2a52d5b4c6cbe4dc0c5d0 100644 (file)
@@ -29,7 +29,7 @@ public interface ListSchemaNode extends DataNodeContainer, AugmentationTarget, D
      *
      * @return List of QNames of leaf identifiers of this list, empty if the list has no keys.
      */
-    @NonNull List<QName> getKeyDefinition();
+    @NonNull List<@NonNull QName> getKeyDefinition();
 
     /**
      * YANG 'ordered-by' statement. It defines whether the order of entries within a list are determined by the user
@@ -44,5 +44,5 @@ public interface ListSchemaNode extends DataNodeContainer, AugmentationTarget, D
      *
      * @return Collection of unique constraints of this list schema node
      */
-    @NonNull Collection<? extends UniqueEffectiveStatement> getUniqueConstraints();
+    @NonNull Collection<? extends @NonNull UniqueEffectiveStatement> getUniqueConstraints();
 }
index b869ad0cc60f48dab263cb66a4eb6830e81d2dd5..09892dfe1e9bfa9e9f276fdbb20283da9808f406 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.model.api;
 import com.google.common.annotations.Beta;
 import java.util.Collection;
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.YangVersion;
@@ -75,10 +76,10 @@ public interface ModuleLike extends DataNodeContainer, DocumentedNode, Immutable
      * @return set of module imports which are specified in the module as the argument of YANG {@code import}
      *         statements.
      */
-    Collection<? extends ModuleImport> getImports();
+    Collection<? extends @NonNull ModuleImport> getImports();
 
     // FIXME: YANGTOOLS-1006: this should be only in Module
-    Collection<? extends Submodule> getSubmodules();
+    Collection<? extends @NonNull Submodule> getSubmodules();
 
     /**
      * Returns {@link FeatureDefinition} instances which contain data from {@code feature} statements defined in the
@@ -90,7 +91,7 @@ public interface ModuleLike extends DataNodeContainer, DocumentedNode, Immutable
      * @return feature statements in lexicographical order which are specified in the module as the argument of YANG
      *         {@code feature} statements.
      */
-    Collection<? extends FeatureDefinition> getFeatures();
+    Collection<? extends @NonNull FeatureDefinition> getFeatures();
 
     /**
      * Returns {@link AugmentationSchemaNode} instances which contain data from {@code augment} statements defined
@@ -99,7 +100,7 @@ public interface ModuleLike extends DataNodeContainer, DocumentedNode, Immutable
      * @return set of the augmentation schema instances which are specified in the module as YANG {@code augment}
      *         statement and are lexicographically ordered
      */
-    Collection<? extends AugmentationSchemaNode> getAugmentations();
+    Collection<? extends @NonNull AugmentationSchemaNode> getAugmentations();
 
     /**
      * Returns {@link RpcDefinition} instances which contain data from {@code rpc} statements defined in the module.
@@ -107,14 +108,14 @@ public interface ModuleLike extends DataNodeContainer, DocumentedNode, Immutable
      * @return set of the RPC definition instances which are specified in the module as YANG {@code rpc} statements and
      *         are lexicographicaly ordered
      */
-    Collection<? extends RpcDefinition> getRpcs();
+    Collection<? extends @NonNull RpcDefinition> getRpcs();
 
     /**
      * Returns {@link Deviation} instances which contain data from {@code deviation} statements defined in the module.
      *
      * @return set of the deviation instances
      */
-    Collection<? extends Deviation> getDeviations();
+    Collection<? extends @NonNull Deviation> getDeviations();
 
     /**
      * Returns {@link IdentitySchemaNode} instances which contain data from {@code identity} statements defined in the
@@ -123,7 +124,7 @@ public interface ModuleLike extends DataNodeContainer, DocumentedNode, Immutable
      * @return set of identity schema node instances which are specified in the module as YANG {@code identity}
      *         statements and are lexicographically ordered
      */
-    Collection<? extends IdentitySchemaNode> getIdentities();
+    Collection<? extends @NonNull IdentitySchemaNode> getIdentities();
 
     /**
      * Returns {@link ExtensionDefinition} instances which contain data from {@code extension} statements defined in
@@ -132,5 +133,5 @@ public interface ModuleLike extends DataNodeContainer, DocumentedNode, Immutable
      * @return set of extension definition instances which are specified in the module as YANG {@code extension}
      *         statements and are lexicographically ordered
      */
-    Collection<? extends ExtensionDefinition> getExtensionSchemaNodes();
+    Collection<? extends @NonNull ExtensionDefinition> getExtensionSchemaNodes();
 }
index 8ec0bd7cc985002c4e2dcd1696c3223c63fe78a8..7e6c10eaa75b4d827e40452860d800bf3f2fd70f 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.model.api;
 
 import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
 
 /**
  * Mix-in interface for nodes which can define must constraints.
@@ -16,10 +17,9 @@ import java.util.Collection;
  */
 public interface MustConstraintAware {
     /**
-     * Specifies the rules which the node which contains <code>must</code> YANG substatement has to match.
+     * Specifies the rules which the node which contains {@code must} YANG substatement has to match.
      *
-     * @return collection of <code>MustDefinition</code> (XPath) instances which represents the concrete data
-     *         constraints
+     * @return collection of {@code MustDefinition} (XPath) instances which represents the concrete data constraints
      */
-    Collection<? extends MustDefinition> getMustConstraints();
+    Collection<? extends @NonNull MustDefinition> getMustConstraints();
 }
index f77caf9af80287b3db732767cd1f9d0364b0c7bd..762a4e9de41ab6f5632da666104a2721f210ea56 100644 (file)
@@ -22,7 +22,7 @@ public interface NotificationNodeContainer {
       *
      * @return set of notification nodes
      */
-    @NonNull Collection<? extends NotificationDefinition> getNotifications();
+    @NonNull Collection<? extends @NonNull NotificationDefinition> getNotifications();
 
     /**
      * Find a notification based on its QName. Default implementation searches the set returned by
index b06d397ceb43f03fc5d2df9b1c8206b037f3df29..1494337cbeacc1442b4d754d989d3d957b1e1463 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.model.api;
 
 import com.google.common.annotations.Beta;
 import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
 
 /**
  * Common interface for an operation.
@@ -20,14 +21,14 @@ public interface OperationDefinition extends SchemaNode {
      *
      * @return Set of type definitions declared under this operation.
      */
-    Collection<? extends TypeDefinition<?>> getTypeDefinitions();
+    Collection<? extends @NonNull TypeDefinition<?>> getTypeDefinitions();
 
     /**
      * Returns the set of grouping statements declared under this operation.
      *
      * @return Set of grouping statements declared under this operation.
      */
-    Collection<? extends GroupingDefinition> getGroupings();
+    Collection<? extends @NonNull GroupingDefinition> getGroupings();
 
     /**
      * Returns definition of input parameters for this operation.
index 0a94ddd3b6d836b30fe7ed863676d66fbcbbf200..0e74f13f519d45145d601308d31baf84fb9612d2 100644 (file)
@@ -49,7 +49,7 @@ public interface SchemaContext extends ContainerLike, Immutable {
      * @return set of <code>DataSchemaNode</code> instances which represents
      *         YANG data nodes at the module top level
      */
-    Collection<? extends DataSchemaNode> getDataDefinitions();
+    @NonNull Collection<? extends @NonNull DataSchemaNode> getDataDefinitions();
 
     /**
      * Returns modules which are part of the schema context. Returned set is required to have its iteration ordered
@@ -58,7 +58,7 @@ public interface SchemaContext extends ContainerLike, Immutable {
      *
      * @return set of the modules which belong to the schema context
      */
-    Collection<? extends Module> getModules();
+    @NonNull Collection<? extends @NonNull Module> getModules();
 
     /**
      * Returns rpc definition instances which are defined as the direct
@@ -67,7 +67,7 @@ public interface SchemaContext extends ContainerLike, Immutable {
      * @return set of <code>RpcDefinition</code> instances which represents
      *         nodes defined via <code>rpc</code> YANG keyword
      */
-    Collection<? extends RpcDefinition> getOperations();
+    @NonNull Collection<? extends @NonNull RpcDefinition> getOperations();
 
     /**
      * Returns extension definition instances which are defined as the direct
@@ -76,7 +76,7 @@ public interface SchemaContext extends ContainerLike, Immutable {
      * @return set of <code>ExtensionDefinition</code> instances which
      *         represents nodes defined via <code>extension</code> YANG keyword
      */
-    Collection<? extends ExtensionDefinition> getExtensions();
+    @NonNull Collection<? extends ExtensionDefinition> getExtensions();
 
     /**
      * Returns the module matching specified {@link QNameModule}, if present.
@@ -170,7 +170,7 @@ public interface SchemaContext extends ContainerLike, Immutable {
      *            string with the module name
      * @return set of module instances with specified name.
      */
-    default Collection<? extends Module> findModules(final String name) {
+    default @NonNull Collection<? extends @NonNull Module> findModules(final String name) {
         return Collections2.filter(getModules(), m -> name.equals(m.getName()));
     }
 
@@ -183,7 +183,7 @@ public interface SchemaContext extends ContainerLike, Immutable {
      * @return module instance which has namespace equal to the
      *         <code>namespace</code> or <code>null</code> in other cases
      */
-    default Collection<? extends Module> findModules(final URI namespace) {
+    default @NonNull Collection<? extends @NonNull Module> findModules(final URI namespace) {
         return Collections2.filter(getModules(), m -> namespace.equals(m.getNamespace()));
     }
 
@@ -202,7 +202,7 @@ public interface SchemaContext extends ContainerLike, Immutable {
 
     @Override
     default Optional<NotificationDefinition> findNotification(final QName qname) {
-        final Optional<Collection<? extends NotificationDefinition>> defs = findModule(qname.getModule())
+        final Optional<Collection<? extends @NonNull NotificationDefinition>> defs = findModule(qname.getModule())
                 .map(Module::getNotifications);
         if (defs.isPresent()) {
             for (NotificationDefinition def : defs.get()) {
@@ -228,7 +228,7 @@ public interface SchemaContext extends ContainerLike, Immutable {
 
     @Override
     @Deprecated
-    default Collection<? extends MustDefinition> getMustConstraints() {
+    default Collection<? extends @NonNull MustDefinition> getMustConstraints() {
         return ImmutableSet.of();
     }
 
index bb6e4d5338cb681a747e6880fd06b9527ca043c3..bff2296f6933f1c841d2a5efcbb9fef652f2f5dd 100644 (file)
@@ -62,7 +62,7 @@ public interface EffectiveStatement<A, D extends DeclaredStatement<A>> extends M
      *
      * @return collection of all effective substatements.
      */
-    @NonNull Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements();
+    @NonNull Collection<? extends @NonNull EffectiveStatement<?, ?>> effectiveSubstatements();
 
     /**
      * Find the first effective substatement of specified type.
index 9a6595eaab203e280e46f500fae3f98e949359c8..ea6a4f3dbdb6bae5cc436d4db12e5894fb975b0d 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.model.api.type;
 
 import com.google.common.collect.RangeSet;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
 
 /**
@@ -20,5 +21,5 @@ public interface RangeConstraint<T extends Number & Comparable<T>> extends Const
      *
      * @return Set of allowed lengths.
      */
-    RangeSet<T> getAllowedRanges();
+    RangeSet<@NonNull T> getAllowedRanges();
 }
index 77c5563a2b4eb9e9829e5065a3430649f7cc1ec8..c94c5acf1a67c1c88b9b717444196717856b89b1 100644 (file)
@@ -14,4 +14,7 @@ module org.opendaylight.yangtools.yang.model.util {
 
     requires org.opendaylight.yangtools.util;
     requires org.slf4j;
+
+    // Annotations
+    requires static transitive org.eclipse.jdt.annotation;
 }
index 913edc3b01d7d592148cc2b7a76f2c19911acc9b..7481c7214e9254545f4b97c00c6291102c704bcf 100644 (file)
@@ -29,6 +29,7 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import java.util.TreeSet;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -236,7 +237,7 @@ public abstract class AbstractSchemaContext implements SchemaContext {
                 Multimaps.newSetMultimap(new HashMap<>(), HashSet::new);
         final List<IdentitySchemaNode> identities = new ArrayList<>();
         for (Module module : getModules()) {
-            final Collection<? extends IdentitySchemaNode> ids = module.getIdentities();
+            final Collection<? extends @NonNull IdentitySchemaNode> ids = module.getIdentities();
             for (IdentitySchemaNode identity : ids) {
                 for (IdentitySchemaNode base : identity.getBaseIdentities()) {
                     tmp.put(base, identity);
index ec3c9e958ab295e94caf8e86561462c5e47b7f8a..d858276c901dd803a94a8f887b44fe63dbec9850 100644 (file)
@@ -33,6 +33,7 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.function.Function;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.Module;
@@ -123,8 +124,9 @@ public final class FilteringSchemaContextProxy extends AbstractSchemaContext {
     }
 
     //dealing with imported module other than root and directly importing root
-    private static Collection<Module> getImportedModules(final Map<ModuleId, ? extends Module> allModules,
-            final Collection<? extends Module> baseModules, final TreeMultimap<String, Module> nameToModulesAll) {
+    private static Collection<Module> getImportedModules(final Map<ModuleId, ? extends @NonNull Module> allModules,
+            final Collection<? extends @NonNull Module> baseModules,
+            final TreeMultimap<String, Module> nameToModulesAll) {
 
         List<Module> relatedModules = new LinkedList<>();
 
index 43804dee27829f7a367e7adb4ee4b5e50b5e379f..3603810ff471e81ba3c8ac2bc389ab37b9f50861 100644 (file)
@@ -26,6 +26,7 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import java.util.TreeMap;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.rfc7952.model.api.AnnotationSchemaNode;
 import org.opendaylight.yangtools.rfc7952.model.api.AnnotationSchemaNodeAwareSchemaContext;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -45,7 +46,7 @@ public class SimpleSchemaContext extends AbstractSchemaContext implements Annota
     private final ImmutableSet<Module> modules;
     private final ImmutableMap<QName, AnnotationSchemaNode> annotations;
 
-    protected SimpleSchemaContext(final Collection<? extends Module> modules) {
+    protected SimpleSchemaContext(final Collection<? extends @NonNull Module> modules) {
         /*
          * Instead of doing this on each invocation of getModules(), pre-compute it once and keep it around -- better
          * than the set we got in.
index 178ef2123d30c794da93cf1fff63493e5862b46a..93d41f30030cccd5817bb0448ed6ff5fe59e68a0 100644 (file)
@@ -12,13 +12,14 @@ import static java.util.Objects.requireNonNull;
 import com.google.common.collect.ImmutableRangeSet;
 import com.google.common.collect.RangeSet;
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 
 final class ResolvedRangeConstraint<T extends Number & Comparable<T>> implements RangeConstraint<T>, Immutable {
+    private final ImmutableRangeSet<@NonNull T> ranges;
     private final ConstraintMetaDefinition meta;
-    private final ImmutableRangeSet<T> ranges;
 
     ResolvedRangeConstraint(final ConstraintMetaDefinition meta, final RangeSet<T> ranges) {
         this.meta = requireNonNull(meta);
@@ -46,7 +47,7 @@ final class ResolvedRangeConstraint<T extends Number & Comparable<T>> implements
     }
 
     @Override
-    public RangeSet<T> getAllowedRanges() {
+    public RangeSet<@NonNull T> getAllowedRanges() {
         return ranges;
     }
 }
index 19fd331047150257eed9ca91198b3f396c51b963..f4f8af2f8d0228c6c7edcf5043ae01ddbd175153 100644 (file)
@@ -80,7 +80,7 @@ public abstract class AbstractEffectiveStatement<A, D extends DeclaredStatement<
      * @throws ClassCastException if masked object does not match EffectiveStatement
      */
     @SuppressWarnings({ "rawtypes", "unchecked" })
-    protected static final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> unmaskList(
+    protected static final @NonNull ImmutableList<? extends @NonNull EffectiveStatement<?, ?>> unmaskList(
             final @NonNull Object masked) {
         return (ImmutableList) unmaskList(masked, EffectiveStatement.class);
     }
index e16d066b49207e6d002b90ccf3fd1d9a79e0d285..91af95ff5e44724076ccb9d7a83396709eb36975 100644 (file)
@@ -68,7 +68,7 @@ public final class EffectiveStatementMixins {
     // Marker interface requiring all mixins to be derived from EffectiveStatement.
     private interface Mixin<A, D extends DeclaredStatement<A>> extends EffectiveStatement<A, D> {
         @SuppressWarnings("unchecked")
-        default <T> @NonNull Collection<? extends T> filterEffectiveStatements(final Class<T> type) {
+        default <T> @NonNull Collection<? extends @NonNull T> filterEffectiveStatements(final Class<T> type) {
             // Yeah, this is not nice, but saves one transformation
             return (Collection<? extends T>) Collections2.filter(effectiveSubstatements(), type::isInstance);
         }
@@ -138,7 +138,7 @@ public final class EffectiveStatementMixins {
      */
     public interface MustConstraintMixin<A, D extends DeclaredStatement<A>> extends Mixin<A, D>, MustConstraintAware {
         @Override
-        default Collection<? extends MustDefinition> getMustConstraints() {
+        default Collection<? extends @NonNull MustDefinition> getMustConstraints() {
             return filterEffectiveStatements(MustDefinition.class);
         }
     }
@@ -417,12 +417,12 @@ public final class EffectiveStatementMixins {
         }
 
         @Override
-        default Collection<? extends TypeDefinition<?>> getTypeDefinitions() {
+        default Collection<? extends @NonNull TypeDefinition<?>> getTypeDefinitions() {
             return filterTypeDefinitions(this);
         }
 
         @Override
-        default Collection<? extends GroupingDefinition> getGroupings() {
+        default Collection<? extends @NonNull GroupingDefinition> getGroupings() {
             return filterEffectiveStatements(GroupingDefinition.class);
         }
 
@@ -556,11 +556,11 @@ public final class EffectiveStatementMixins {
     }
 
     static <T extends ContainerLike> T findAsContainer(final EffectiveStatement<?, ?> stmt,
-            final Class<? extends EffectiveStatement<QName, ?>> type, Class<T> target) {
+            final Class<? extends EffectiveStatement<QName, ?>> type, final Class<T> target) {
         return target.cast(stmt.findFirstEffectiveSubstatement(type).get());
     }
 
-    static Collection<? extends TypeDefinition<?>> filterTypeDefinitions(final Mixin<?, ?> stmt) {
+    static Collection<? extends @NonNull TypeDefinition<?>> filterTypeDefinitions(final Mixin<?, ?> stmt) {
         return Collections2.transform(stmt.filterEffectiveStatements(TypedefEffectiveStatement.class),
             TypedefEffectiveStatement::getTypeDefinition);
     }
index ee35b794b397d9df6866c9e64cce08fc673053a4..f5b24abadb0122b395cc0ce52b3e2ca01ff00be0 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.deviate;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
 import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.DeviateDefinition;
 import org.opendaylight.yangtools.yang.model.api.DeviateKind;
 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
@@ -67,7 +68,7 @@ final class DeviateEffectiveStatementImpl extends WithSubstatements<DeviateKind,
     }
 
     @Override
-    public Collection<? extends MustDefinition> getDeviatedMusts() {
+    public Collection<? extends @NonNull MustDefinition> getDeviatedMusts() {
         return allSubstatementsOfType(MustDefinition.class);
     }
 
@@ -78,7 +79,7 @@ final class DeviateEffectiveStatementImpl extends WithSubstatements<DeviateKind,
     }
 
     @Override
-    public Collection<? extends UniqueEffectiveStatement> getDeviatedUniques() {
+    public Collection<? extends @NonNull UniqueEffectiveStatement> getDeviatedUniques() {
         return allSubstatementsOfType(UniqueEffectiveStatement.class);
     }
 
index 870d01d83066b67e8d40e0265e4a8232b932df84..eaeb52aaf36dd94377787e78d0810588a8a23bfe 100644 (file)
@@ -18,6 +18,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.YangConstants;
@@ -99,7 +100,7 @@ public final class TestUtils {
         return ctx.getModules().iterator().next();
     }
 
-    public static Optional<? extends Module> findModule(final SchemaContext context, final String moduleName) {
+    public static Optional<? extends @NonNull Module> findModule(final SchemaContext context, final String moduleName) {
         return context.getModules().stream().filter(module -> moduleName.equals(module.getName())).findAny();
     }