Migrate SchemaSourceRepresentation annotations 32/77232/5
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 23 Oct 2018 20:46:15 +0000 (22:46 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 24 Oct 2018 08:32:56 +0000 (10:32 +0200)
Migrate from JSR305 to JDT annotations, along with implentations.

Change-Id: I38c8c567a91c42e0c4387cfc3d7baf06cf495e2b
JIRA: YANGTOOLS-907
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 files changed:
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/DelegatedYangTextSchemaSource.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/DelegatedYinTextSchemaSource.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/ResourceYangTextSchemaSource.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/ResourceYinTextSchemaSource.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/SchemaSourceRepresentation.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YangSchemaSourceRepresentation.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YangTextSchemaSource.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinDomSchemaSource.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinSchemaSourceRepresentation.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinTextFileSchemaSource.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinTextSchemaSource.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/YinXmlSchemaSource.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/ASTSchemaSource.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YangModelDependencyInfo.java

index 86887280ad14f330df00e5bf13e99fd2c27fe778..c2c6d02625f3abbeb007fca73d66d2dc538efd74 100644 (file)
@@ -14,10 +14,11 @@ import com.google.common.io.ByteSource;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Delegator;
 
 final class DelegatedYangTextSchemaSource extends YangTextSchemaSource implements Delegator<ByteSource> {
-    private final ByteSource delegate;
+    private final @NonNull ByteSource delegate;
 
     DelegatedYangTextSchemaSource(final SourceIdentifier identifier, final ByteSource delegate) {
         super(identifier);
index 768e94fd8ca968ad58f7b9ac7ce94716702b84f5..d88b912d6457a9f63bc63d1bf7a36c266156bda4 100644 (file)
@@ -14,10 +14,11 @@ import com.google.common.io.ByteSource;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Delegator;
 
 final class DelegatedYinTextSchemaSource extends YinTextSchemaSource implements Delegator<ByteSource> {
-    private final ByteSource delegate;
+    private final @NonNull ByteSource delegate;
 
     DelegatedYinTextSchemaSource(final SourceIdentifier identifier, final ByteSource delegate) {
         super(identifier);
index c0aed5f703e6b32bde3930b137039f24e5426f0e..b00b7504662e1d55bfab6db74596b306e0e63b95 100644 (file)
@@ -15,6 +15,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Delegator;
 
 /**
@@ -23,7 +24,7 @@ import org.opendaylight.yangtools.concepts.Delegator;
 @Beta
 // FIXME: YANGTOOLS-849: 3.0.0: hide this class
 public final class ResourceYangTextSchemaSource extends YangTextSchemaSource implements Delegator<URL> {
-    private final URL url;
+    private final @NonNull URL url;
 
     ResourceYangTextSchemaSource(final SourceIdentifier identifier, final URL url) {
         super(identifier);
index b548ebb73b9afe95479ae697cf1ef17f666f99d5..e929ae947c013602be309bc432e3403ee8c211ca 100644 (file)
@@ -7,23 +7,25 @@
  */
 package org.opendaylight.yangtools.yang.model.repo.api;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Delegator;
 
 /**
  * A resource-backed {@link YangTextSchemaSource}.
  */
 final class ResourceYinTextSchemaSource extends YinTextSchemaSource implements Delegator<URL> {
-    private final URL url;
+    private final @NonNull URL url;
 
     ResourceYinTextSchemaSource(final SourceIdentifier identifier, final URL url) {
         super(identifier);
-        this.url = Preconditions.checkNotNull(url);
+        this.url = requireNonNull(url);
     }
 
     @Override
index 4df8e7eb9a1525fc314cb22c93739d2a32f4ea76..431aac46f94a073e298ac56054eccc2815e9bcd6 100644 (file)
@@ -9,25 +9,19 @@ package org.opendaylight.yangtools.yang.model.repo.api;
 
 import com.google.common.annotations.Beta;
 import java.util.Optional;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.concepts.Immutable;
 
 /**
- * Common interface for schema source representations.
+ * Common interface for schema source representations. A schema source is an atomic piece of the overall schema context.
+ * In YANG terms, a schema source is semantically equivalent to a single YANG text file, be it a module or a submodule.
  *
  * <p>
- * A schema source is an atomic piece of the overall schema context. In YANG terms,
- * a schema source is semantically equivalent to a single YANG text file, be it a
- * module or a submodule.
- *
- * <p>
- * A schema source can exist in various forms, which we call representations. Again,
- * in YANG terms, each representation is semantically equivalent, but from
- * implementation perspective certain operations on a schema source may require it
- * to be first transformed into a particular representation before they can be
- * applied. Such transformations are affected via instances of
- * SchemaSourceTransformation.
+ * A schema source can exist in various forms, which we call representations. Again, in YANG terms, each representation
+ * is semantically equivalent, but from implementation perspective certain operations on a schema source may require it
+ * to be first transformed into a particular representation before they can be applied. Such transformations are
+ * affected via instances of SchemaSourceTransformation.
  *
  * <p>
  * Typical examples of a schema source representation include:
@@ -52,7 +46,7 @@ public interface SchemaSourceRepresentation extends Identifiable<SourceIdentifie
      *
      * @return The type of representation.
      */
-    @Nonnull Class<? extends SchemaSourceRepresentation> getType();
+    @NonNull Class<? extends SchemaSourceRepresentation> getType();
 
     /**
      * Return the symbolic name, if available. This name has no semantic meaning beyond being useful for debugging
index 4bfa55feea5f0827e6b3466f4fcd307a8b6103df..d927c8ce030e8f396d077f4c923d170a7d3dd115 100644 (file)
@@ -7,18 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.model.repo.api;
 
-import javax.annotation.Nonnull;
-
 /**
  * A YANG {@link SchemaSourceRepresentation}.
  */
 public interface YangSchemaSourceRepresentation extends SchemaSourceRepresentation {
-    /**
-     * Return the concrete representation type.
-     *
-     * @return The type of representation.
-     */
-    @Nonnull
     @Override
     Class<? extends YangSchemaSourceRepresentation> getType();
 }
index c23ba4281135d24aa39b087961062e1511a70675..d6c8873a7fc21e57435d611db49416298fa58f71 100644 (file)
@@ -21,7 +21,7 @@ import java.io.File;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Map.Entry;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.Revision;
 
 /**
@@ -30,13 +30,13 @@ import org.opendaylight.yangtools.yang.common.Revision;
  */
 @Beta
 public abstract class YangTextSchemaSource extends ByteSource implements YangSchemaSourceRepresentation {
-    private final SourceIdentifier identifier;
+    private final @NonNull SourceIdentifier identifier;
 
     protected YangTextSchemaSource(final SourceIdentifier identifier) {
         this.identifier = requireNonNull(identifier);
     }
 
-    public static SourceIdentifier identifierFromFilename(final String name) {
+    public static @NonNull SourceIdentifier identifierFromFilename(final String name) {
         checkArgument(name.endsWith(RFC6020_YANG_FILE_EXTENSION), "Filename %s does not end with '%s'",
             RFC6020_YANG_FILE_EXTENSION, name);
 
@@ -53,7 +53,7 @@ public abstract class YangTextSchemaSource extends ByteSource implements YangSch
      * @param delegate Backing ByteSource instance
      * @return A new YangTextSchemaSource
      */
-    public static YangTextSchemaSource delegateForByteSource(final SourceIdentifier identifier,
+    public static @NonNull YangTextSchemaSource delegateForByteSource(final SourceIdentifier identifier,
             final ByteSource delegate) {
         return new DelegatedYangTextSchemaSource(identifier, delegate);
     }
@@ -67,7 +67,8 @@ public abstract class YangTextSchemaSource extends ByteSource implements YangSch
      * @return A new YangTextSchemaSource
      * @throws IllegalArgumentException if the file name has invalid format
      */
-    public static YangTextSchemaSource delegateForByteSource(final String fileName, final ByteSource delegate) {
+    public static @NonNull YangTextSchemaSource delegateForByteSource(final String fileName,
+            final ByteSource delegate) {
         return new DelegatedYangTextSchemaSource(identifierFromFilename(fileName), delegate);
     }
 
@@ -80,7 +81,7 @@ public abstract class YangTextSchemaSource extends ByteSource implements YangSch
      * @throws IllegalArgumentException if the file name has invalid format or if the supplied File is not a file
      * @throws NullPointerException if file is null
      */
-    public static YangTextSchemaSource forFile(final File file) {
+    public static @NonNull YangTextSchemaSource forFile(final File file) {
         checkArgument(file.isFile(), "Supplied file %s is not a file", file);
         return new YangTextFileSchemaSource(identifierFromFilename(file.getName()), file);
     }
@@ -94,7 +95,7 @@ public abstract class YangTextSchemaSource extends ByteSource implements YangSch
      * @throws IllegalArgumentException if the resource does not exist or if the name has invalid format
      */
     // FIXME: 3.0.0: YANGTOOLS-849: return YangTextSchemaSource
-    public static ResourceYangTextSchemaSource forResource(final String resourceName) {
+    public static @NonNull ResourceYangTextSchemaSource forResource(final String resourceName) {
         return forResource(YangTextSchemaSource.class, resourceName);
     }
 
@@ -108,7 +109,7 @@ public abstract class YangTextSchemaSource extends ByteSource implements YangSch
      * @throws IllegalArgumentException if the resource does not exist or if the name has invalid format
      */
     // FIXME: 3.0.0: YANGTOOLS-849: return YangTextSchemaSource
-    public static ResourceYangTextSchemaSource forResource(final Class<?> clazz, final String resourceName) {
+    public static @NonNull ResourceYangTextSchemaSource forResource(final Class<?> clazz, final String resourceName) {
         final String fileName = resourceName.substring(resourceName.lastIndexOf('/') + 1);
         final SourceIdentifier identifier = identifierFromFilename(fileName);
         final URL url = Resources.getResource(clazz, resourceName);
@@ -120,7 +121,6 @@ public abstract class YangTextSchemaSource extends ByteSource implements YangSch
         return identifier;
     }
 
-    @Nonnull
     @Override
     public Class<? extends YangTextSchemaSource> getType() {
         return YangTextSchemaSource.class;
index 1459d53eaff05b595f181cddec0e0e1687f25c2d..2d037474fab06ed626b3f59085dbab11770256e6 100644 (file)
@@ -16,12 +16,13 @@ import static org.opendaylight.yangtools.yang.model.api.YangStmtMapping.SUBMODUL
 
 import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
-import javax.annotation.Nonnull;
 import javax.xml.transform.Source;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.YangConstants;
@@ -51,8 +52,8 @@ public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
      * @param source W3C DOM source
      * @return A new {@link YinDomSchemaSource} instance.
      */
-    public static @Nonnull YinDomSchemaSource create(@Nonnull final SourceIdentifier identifier,
-            final @Nonnull DOMSource source) {
+    public static @NonNull YinDomSchemaSource create(final @NonNull SourceIdentifier identifier,
+            final @NonNull DOMSource source) {
 
         final Node root = source.getNode().getFirstChild();
         final String rootNs = root.getNamespaceURI();
@@ -105,7 +106,7 @@ public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
      * @param xmlSchemaSource Backing schema source
      * @return A {@link YinDomSchemaSource} instance
      */
-    @Nonnull public static YinDomSchemaSource lazyTransform(final YinXmlSchemaSource xmlSchemaSource) {
+    public static @NonNull YinDomSchemaSource lazyTransform(final YinXmlSchemaSource xmlSchemaSource) {
         final YinDomSchemaSource cast = castSchemaSource(xmlSchemaSource);
         return cast != null ? cast : new Transforming(xmlSchemaSource);
     }
@@ -118,7 +119,7 @@ public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
      * @return A {@link YinDomSchemaSource} instance
      * @throws TransformerException when the provided source fails to transform
      */
-    @Nonnull public static YinDomSchemaSource transform(final YinXmlSchemaSource xmlSchemaSource)
+    public static @NonNull YinDomSchemaSource transform(final YinXmlSchemaSource xmlSchemaSource)
             throws TransformerException {
         final YinDomSchemaSource cast = castSchemaSource(xmlSchemaSource);
         return cast != null ? cast :
@@ -126,7 +127,7 @@ public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
     }
 
     @Override
-    @Nonnull public abstract DOMSource getSource();
+    public abstract DOMSource getSource();
 
     @Override
     public final Class<? extends YinXmlSchemaSource> getType() {
@@ -149,14 +150,14 @@ public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
      */
     protected abstract ToStringHelper addToStringAttributes(ToStringHelper toStringHelper);
 
-    static DOMSource transformSource(final Source source) throws TransformerException {
+    static @NonNull DOMSource transformSource(final Source source) throws TransformerException {
         final DOMResult result = new DOMResult();
         TRANSFORMER_FACTORY.newTransformer().transform(source, result);
 
         return new DOMSource(result.getNode(), result.getSystemId());
     }
 
-    private static YinDomSchemaSource castSchemaSource(final YinXmlSchemaSource xmlSchemaSource) {
+    private static @Nullable YinDomSchemaSource castSchemaSource(final YinXmlSchemaSource xmlSchemaSource) {
         if (xmlSchemaSource instanceof YinDomSchemaSource) {
             return (YinDomSchemaSource) xmlSchemaSource;
         }
@@ -170,15 +171,14 @@ public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
     }
 
     private static final class Simple extends YinDomSchemaSource {
-        private final SourceIdentifier identifier;
-        private final DOMSource source;
+        private final @NonNull SourceIdentifier identifier;
+        private final @NonNull DOMSource source;
 
-        Simple(@Nonnull final SourceIdentifier identifier, @Nonnull final DOMSource source) {
+        Simple(final @NonNull SourceIdentifier identifier, final @NonNull DOMSource source) {
             this.identifier = requireNonNull(identifier);
             this.source = requireNonNull(source);
         }
 
-        @Nonnull
         @Override
         public DOMSource getSource() {
             return source;
@@ -203,7 +203,6 @@ public abstract class YinDomSchemaSource implements YinXmlSchemaSource {
             this.xmlSchemaSource = requireNonNull(xmlSchemaSource);
         }
 
-        @Nonnull
         @Override
         public DOMSource getSource() {
             DOMSource ret = source;
index 6134babcf21b53bd3d7395c043130e2aaa471f6a..5b2d6ced914e70f0a2698f2cfc92fe8a531d4b09 100644 (file)
@@ -7,18 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.model.repo.api;
 
-import javax.annotation.Nonnull;
-
 /**
  * A YIN {@link SchemaSourceRepresentation}.
  */
 public interface YinSchemaSourceRepresentation extends SchemaSourceRepresentation {
-    /**
-     * Return the concrete representation type.
-     *
-     * @return The type of representation.
-     */
-    @Nonnull
     @Override
     Class<? extends YinSchemaSourceRepresentation> getType();
 }
index 5beabfaa6b86b69454291891d5e8adde00a677f7..c3ec26f68f267747f5e44ccafadccafb44483fff 100644 (file)
@@ -7,13 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.model.repo.api;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Delegator;
 
 /**
@@ -24,9 +26,9 @@ import org.opendaylight.yangtools.concepts.Delegator;
 final class YinTextFileSchemaSource extends YinTextSchemaSource implements Delegator<File> {
     private final File file;
 
-    YinTextFileSchemaSource(final SourceIdentifier identifier, final File file) {
+    YinTextFileSchemaSource(final @NonNull SourceIdentifier identifier, final @NonNull File file) {
         super(identifier);
-        this.file = Preconditions.checkNotNull(file);
+        this.file = requireNonNull(file);
     }
 
     @Override
index b13c26ab47e50c3ecc0c4d6711456e7e1fc6525d..cead5fe4f53ac7e17a146ea4150eddb0d479e424 100644 (file)
@@ -17,9 +17,8 @@ import com.google.common.io.ByteSource;
 import com.google.common.io.Resources;
 import java.io.File;
 import java.io.InputStream;
-import java.net.URL;
 import java.util.Map.Entry;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.common.YangNames;
@@ -34,13 +33,13 @@ public abstract class YinTextSchemaSource extends ByteSource implements YinSchem
     private static final Logger LOG = LoggerFactory.getLogger(YinTextSchemaSource.class);
     private static final String XML_EXTENSION = ".xml";
 
-    private final SourceIdentifier identifier;
+    private final @NonNull SourceIdentifier identifier;
 
     protected YinTextSchemaSource(final SourceIdentifier identifier) {
         this.identifier = requireNonNull(identifier);
     }
 
-    public static SourceIdentifier identifierFromFilename(final String name) {
+    public static @NonNull SourceIdentifier identifierFromFilename(final String name) {
         final String baseName;
         if (name.endsWith(YangConstants.RFC6020_YIN_FILE_EXTENSION)) {
             baseName = name.substring(0, name.length() - YangConstants.RFC6020_YIN_FILE_EXTENSION.length());
@@ -61,7 +60,6 @@ public abstract class YinTextSchemaSource extends ByteSource implements YinSchem
         return identifier;
     }
 
-    @Nonnull
     @Override
     public Class<? extends YinTextSchemaSource> getType() {
         return YinTextSchemaSource.class;
@@ -81,7 +79,7 @@ public abstract class YinTextSchemaSource extends ByteSource implements YinSchem
      * @param toStringHelper ToStringHelper onto the attributes can be added
      * @return ToStringHelper supplied as input argument.
      */
-    protected abstract ToStringHelper addToStringAttributes(ToStringHelper toStringHelper);
+    protected abstract ToStringHelper addToStringAttributes(@NonNull ToStringHelper toStringHelper);
 
     /**
      * Create a new YinTextSchemaSource with a specific source identifier and backed
@@ -91,20 +89,19 @@ public abstract class YinTextSchemaSource extends ByteSource implements YinSchem
      * @param delegate Backing ByteSource instance
      * @return A new YinTextSchemaSource
      */
-    public static YinTextSchemaSource delegateForByteSource(final SourceIdentifier identifier,
+    public static @NonNull YinTextSchemaSource delegateForByteSource(final SourceIdentifier identifier,
             final ByteSource delegate) {
         return new DelegatedYinTextSchemaSource(identifier, delegate);
     }
 
-    public static YinTextSchemaSource forFile(final File file) {
+    public static @NonNull YinTextSchemaSource forFile(final File file) {
         checkArgument(file.isFile(), "Supplied file %s is not a file", file);
         return new YinTextFileSchemaSource(identifierFromFilename(file.getName()), file);
     }
 
-    public static YinTextSchemaSource forResource(final Class<?> clazz, final String resourceName) {
+    public static @NonNull YinTextSchemaSource forResource(final Class<?> clazz, final String resourceName) {
         final String fileName = resourceName.substring(resourceName.lastIndexOf('/') + 1);
-        final SourceIdentifier identifier = identifierFromFilename(fileName);
-        final URL url = Resources.getResource(clazz, resourceName);
-        return new ResourceYinTextSchemaSource(identifier, url);
+        return new ResourceYinTextSchemaSource(identifierFromFilename(fileName),
+            Resources.getResource(clazz, resourceName));
     }
 }
index 36f47658ac7b2c4278c245c9668102236f0b2c52..4bd18ee53a1b1fbe8e20483aa936b2c0eca89a1b 100644 (file)
@@ -8,15 +8,14 @@
 package org.opendaylight.yangtools.yang.model.repo.api;
 
 import com.google.common.annotations.Beta;
-import javax.annotation.Nonnull;
 import javax.xml.transform.Source;
+import org.eclipse.jdt.annotation.NonNull;
 
 /**
  * YIN text schema source representation. Exposes an RFC6020 or RFC7950 XML representation as an XML {@link Source}.
  */
 @Beta
 public interface YinXmlSchemaSource extends YinSchemaSourceRepresentation {
-    @Nonnull
     @Override
     Class<? extends YinXmlSchemaSource> getType();
 
@@ -25,5 +24,5 @@ public interface YinXmlSchemaSource extends YinSchemaSourceRepresentation {
      *
      * @return An XML {@link Source} instance.
      */
-    @Nonnull Source getSource();
+    @NonNull Source getSource();
 }
index 63e7a9998df50395ae39228676b725055850cf37..85d3acb32fc0ba67be655d87b1134dd9e2310123 100644 (file)
@@ -12,9 +12,9 @@ import static java.util.Objects.requireNonNull;
 import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects;
 import java.util.Optional;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 import org.antlr.v4.runtime.ParserRuleContext;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
@@ -32,14 +32,14 @@ import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
  */
 @Beta
 public final class ASTSchemaSource implements SchemaSourceRepresentation {
-    private final YangModelDependencyInfo depInfo;
-    private final SemVerSourceIdentifier semVerId;
-    private final SourceIdentifier identifier;
-    private final ParserRuleContext tree;
-    private final String symbolicName;
-
-    private ASTSchemaSource(@Nonnull final SourceIdentifier identifier, @Nonnull final SemVerSourceIdentifier semVerId,
-            @Nonnull final ParserRuleContext tree, @Nonnull final YangModelDependencyInfo depInfo,
+    private final @NonNull YangModelDependencyInfo depInfo;
+    private final @NonNull SemVerSourceIdentifier semVerId;
+    private final @NonNull SourceIdentifier identifier;
+    private final @NonNull ParserRuleContext tree;
+    private final @Nullable String symbolicName;
+
+    private ASTSchemaSource(final @NonNull SourceIdentifier identifier, final @NonNull SemVerSourceIdentifier semVerId,
+            final @NonNull ParserRuleContext tree, final @NonNull YangModelDependencyInfo depInfo,
             @Nullable final String symbolicName) {
         this.depInfo = requireNonNull(depInfo);
         this.tree = requireNonNull(tree);
@@ -62,8 +62,8 @@ public final class ASTSchemaSource implements SchemaSourceRepresentation {
      * @throws YangSyntaxErrorException
      *             if we fail to extract dependency information.
      */
-    static ASTSchemaSource create(@Nonnull final SourceIdentifier identifier,
-            @Nullable final String symbolicName, @Nonnull final ParserRuleContext tree)
+    static @NonNull ASTSchemaSource create(final @NonNull SourceIdentifier identifier,
+            final @Nullable String symbolicName, final @NonNull ParserRuleContext tree)
                     throws YangSyntaxErrorException {
         final YangModelDependencyInfo depInfo = YangModelDependencyInfo.fromAST(identifier, tree);
         final SourceIdentifier id = getSourceId(depInfo);
@@ -78,7 +78,6 @@ public final class ASTSchemaSource implements SchemaSourceRepresentation {
         return new ASTSchemaSource(id, semVerId, tree, depInfo, symbolicName);
     }
 
-
     @Override
     public SourceIdentifier getIdentifier() {
         return identifier;
@@ -89,11 +88,10 @@ public final class ASTSchemaSource implements SchemaSourceRepresentation {
         return Optional.ofNullable(symbolicName);
     }
 
-    public SemVerSourceIdentifier getSemVerIdentifier() {
+    public @NonNull SemVerSourceIdentifier getSemVerIdentifier() {
         return semVerId;
     }
 
-    @Nonnull
     @Override
     public Class<? extends SchemaSourceRepresentation> getType() {
         return ASTSchemaSource.class;
@@ -104,7 +102,7 @@ public final class ASTSchemaSource implements SchemaSourceRepresentation {
      *
      * @return Underlying AST.
      */
-    @Nonnull public ParserRuleContext getAST() {
+    public @NonNull ParserRuleContext getAST() {
         return tree;
     }
 
@@ -115,7 +113,7 @@ public final class ASTSchemaSource implements SchemaSourceRepresentation {
      */
     // FIXME: this method should be extracted into a public interface in the model.api.repo class, relying solely
     //        on model.api types.
-    @Nonnull public YangModelDependencyInfo getDependencyInformation() {
+    public @NonNull YangModelDependencyInfo getDependencyInformation() {
         return depInfo;
     }
 
@@ -124,13 +122,13 @@ public final class ASTSchemaSource implements SchemaSourceRepresentation {
         return MoreObjects.toStringHelper(this).add("identifier", identifier).toString();
     }
 
-    private static SourceIdentifier getSourceId(final YangModelDependencyInfo depInfo) {
+    private static @NonNull SourceIdentifier getSourceId(final @NonNull YangModelDependencyInfo depInfo) {
         final String name = depInfo.getName();
         return depInfo.getFormattedRevision() == null ? RevisionSourceIdentifier.create(name)
                 : RevisionSourceIdentifier.create(name, depInfo.getRevision());
     }
 
-    private static SemVerSourceIdentifier getSemVerSourceId(final YangModelDependencyInfo depInfo) {
+    private static @NonNull SemVerSourceIdentifier getSemVerSourceId(final @NonNull YangModelDependencyInfo depInfo) {
         return depInfo.getFormattedRevision() == null
                 ? SemVerSourceIdentifier.create(depInfo.getName(), depInfo.getSemanticVersion().orElse(null))
                         : SemVerSourceIdentifier.create(depInfo.getName(), depInfo.getRevision(),
index 26cc6c4e32bdcd65f78e38db7003f9951d27a424..d06e15ea0612d06eefb52d04b4b15f458df46ffe 100644 (file)
@@ -20,8 +20,9 @@ import java.util.List;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
-import javax.annotation.Nullable;
 import org.antlr.v4.runtime.ParserRuleContext;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser.ArgumentContext;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser.StatementContext;
 import org.opendaylight.yangtools.concepts.SemVer;
@@ -170,7 +171,7 @@ public abstract class YangModelDependencyInfo {
      * @return {@link YangModelDependencyInfo}
      * @throws YangSyntaxErrorException If the AST is not a valid YANG module/submodule
      */
-    static YangModelDependencyInfo fromAST(final SourceIdentifier source, final ParserRuleContext tree)
+    static @NonNull YangModelDependencyInfo fromAST(final SourceIdentifier source, final ParserRuleContext tree)
             throws YangSyntaxErrorException {
 
         if (tree instanceof StatementContext) {
@@ -181,7 +182,7 @@ public abstract class YangModelDependencyInfo {
         throw new YangSyntaxErrorException(source, 0, 0, "Unknown YANG text type");
     }
 
-    private static YangModelDependencyInfo parseAST(final StatementContext rootStatement,
+    private static @NonNull YangModelDependencyInfo parseAST(final StatementContext rootStatement,
             final SourceIdentifier source) {
         final String keyWordText = rootStatement.keyword().getText();
         if (MODULE.equals(keyWordText)) {
@@ -215,7 +216,7 @@ public abstract class YangModelDependencyInfo {
         return parseAST((StatementContext) ast, source.getIdentifier());
     }
 
-    private static YangModelDependencyInfo parseModuleContext(final StatementContext module,
+    private static @NonNull YangModelDependencyInfo parseModuleContext(final StatementContext module,
             final SourceIdentifier source) {
         final String name = safeStringArgument(source, module, "module name");
         final String latestRevision = getLatestRevision(module, source);
@@ -303,7 +304,7 @@ public abstract class YangModelDependencyInfo {
         return latestRevision;
     }
 
-    private static YangModelDependencyInfo parseSubmoduleContext(final StatementContext submodule,
+    private static @NonNull YangModelDependencyInfo parseSubmoduleContext(final StatementContext submodule,
             final SourceIdentifier source) {
         final String name = safeStringArgument(source, submodule, "submodule name");
         final String belongsTo = parseBelongsTo(submodule, source);
@@ -392,11 +393,12 @@ public abstract class YangModelDependencyInfo {
         private final SemVer semVer;
         private final String name;
 
-        ModuleImportImpl(final String moduleName, final Revision revision) {
+        ModuleImportImpl(final @NonNull String moduleName, final @Nullable Revision revision) {
             this(moduleName, revision, null);
         }
 
-        ModuleImportImpl(final String moduleName, @Nullable final Revision revision, @Nullable final SemVer semVer) {
+        ModuleImportImpl(final @NonNull String moduleName, final @Nullable Revision revision,
+                final @Nullable SemVer semVer) {
             this.name = requireNonNull(moduleName, "Module name must not be null.");
             this.revision = revision;
             this.semVer = semVer;