You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2018/08/13 09:38:15 UTC

[sling-org-apache-sling-models-api] branch master updated: SLING-7798 Switch from JSR-305 annotations to JetBrains Nullable/NotNull annotations

This is an automated email from the ASF dual-hosted git repository.

sseifert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-api.git


The following commit(s) were added to refs/heads/master by this push:
     new 2c09265  SLING-7798 Switch from JSR-305 annotations to JetBrains Nullable/NotNull annotations
2c09265 is described below

commit 2c0926541895bb77c33135825ef5f09b8c2cfa6f
Author: sseifert <ss...@pro-vision.de>
AuthorDate: Mon Aug 13 11:38:07 2018 +0200

    SLING-7798 Switch from JSR-305 annotations to JetBrains Nullable/NotNull annotations
---
 pom.xml                                             |  6 +++---
 .../sling/models/export/spi/ModelExporter.java      | 11 +++++------
 .../sling/models/export/spi/package-info.java       |  4 ++--
 .../apache/sling/models/factory/ModelFactory.java   | 21 ++++++++++-----------
 .../apache/sling/models/factory/package-info.java   |  4 ++--
 .../sling/models/spi/DisposalCallbackRegistry.java  |  6 +++---
 .../sling/models/spi/ImplementationPicker.java      |  8 ++++----
 .../java/org/apache/sling/models/spi/Injector.java  | 10 +++++-----
 .../org/apache/sling/models/spi/ValuePreparer.java  |  4 ++--
 .../org/apache/sling/models/spi/package-info.java   |  4 ++--
 10 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/pom.xml b/pom.xml
index a92cdfe..d0fcfb7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,9 +67,9 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>com.google.code.findbugs</groupId>
-            <artifactId>jsr305</artifactId>
-            <version>3.0.0</version>
+            <groupId>org.jetbrains</groupId>
+            <artifactId>annotations</artifactId>
+            <version>16.0.2</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git a/src/main/java/org/apache/sling/models/export/spi/ModelExporter.java b/src/main/java/org/apache/sling/models/export/spi/ModelExporter.java
index 919ebb5..c828b99 100644
--- a/src/main/java/org/apache/sling/models/export/spi/ModelExporter.java
+++ b/src/main/java/org/apache/sling/models/export/spi/ModelExporter.java
@@ -18,11 +18,10 @@ package org.apache.sling.models.export.spi;
 
 import aQute.bnd.annotation.ConsumerType;
 import org.apache.sling.models.factory.ExportException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
 import java.util.Map;
-
 /**
  * SPI interface for model exporters.
  */
@@ -35,7 +34,7 @@ public interface ModelExporter {
      * @param clazz the result class
      * @return true if the result class is supported
      */
-    boolean isSupported(@Nonnull Class<?> clazz);
+    boolean isSupported(@NotNull Class<?> clazz);
 
     /**
      * Export the provided model to the defined class using the options.
@@ -47,12 +46,12 @@ public interface ModelExporter {
      * @return an exported object
      * @throws ExportException if the export is not successful
      */
-    @CheckForNull <T> T export(@Nonnull Object model, @Nonnull Class<T> clazz, @Nonnull Map<String, String> options) throws ExportException;
+    @Nullable <T> T export(@NotNull Object model, @NotNull Class<T> clazz, @NotNull Map<String, String> options) throws ExportException;
 
     /**
      * The name of the exporter.
      * @return the name of the exporter
      */
-    @Nonnull String getName();
+    @NotNull String getName();
 
 }
diff --git a/src/main/java/org/apache/sling/models/export/spi/package-info.java b/src/main/java/org/apache/sling/models/export/spi/package-info.java
index 292b494..1a8bcd5 100644
--- a/src/main/java/org/apache/sling/models/export/spi/package-info.java
+++ b/src/main/java/org/apache/sling/models/export/spi/package-info.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-@Version("1.0.0")
+@Version("1.0.1")
 package org.apache.sling.models.export.spi;
 
-import aQute.bnd.annotation.Version;
\ No newline at end of file
+import aQute.bnd.annotation.Version;
diff --git a/src/main/java/org/apache/sling/models/factory/ModelFactory.java b/src/main/java/org/apache/sling/models/factory/ModelFactory.java
index 78f5bfa..920a3c2 100644
--- a/src/main/java/org/apache/sling/models/factory/ModelFactory.java
+++ b/src/main/java/org/apache/sling/models/factory/ModelFactory.java
@@ -18,10 +18,9 @@
  */
 package org.apache.sling.models.factory;
 
-import javax.annotation.Nonnull;
-
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.resource.Resource;
+import org.jetbrains.annotations.NotNull;
 
 import aQute.bnd.annotation.ProviderType;
 
@@ -46,7 +45,7 @@ public interface ModelFactory {
      * @throws ValidationException in case validation could not be performed for some reason (e.g. no validation information available)
      * @throws InvalidModelException in case the given model type could not be validated through the model validation
      */
-    public @Nonnull <ModelType> ModelType createModel(@Nonnull Object adaptable, @Nonnull Class<ModelType> type) throws MissingElementsException,
+    public @NotNull <ModelType> ModelType createModel(@NotNull Object adaptable, @NotNull Class<ModelType> type) throws MissingElementsException,
             InvalidAdaptableException, ModelClassException, PostConstructException, ValidationException, InvalidModelException;
 
     /**
@@ -55,7 +54,7 @@ public interface ModelFactory {
      * @param type the class to check
      * @return {@code true} in case the given class can be created from the given adaptable, otherwise {@code false}
      */
-    public boolean canCreateFromAdaptable(@Nonnull Object adaptable, @Nonnull Class<?> type);
+    public boolean canCreateFromAdaptable(@NotNull Object adaptable, @NotNull Class<?> type);
 
     /**
      * 
@@ -67,7 +66,7 @@ public interface ModelFactory {
      * @deprecated Use {@link #isModelClass(Class)} instead!
      */
     @Deprecated
-    public boolean isModelClass(@Nonnull Object adaptable, @Nonnull Class<?> type);
+    public boolean isModelClass(@NotNull Object adaptable, @NotNull Class<?> type);
 
     /**
      * Checks if a given type can be instantiated though Sling Models. This checks that
@@ -80,7 +79,7 @@ public interface ModelFactory {
      * @return {@code true} in case the given type can be instantiated though Sling Models. 
      * 
      */
-    public boolean isModelClass(@Nonnull Class<?> type);
+    public boolean isModelClass(@NotNull Class<?> type);
 
     /**
      * Determine is a model class is available for the resource's resource type.
@@ -88,7 +87,7 @@ public interface ModelFactory {
      * @param resource a resource
      * @return {@code true} if a model class is mapped to the resource type
      */
-    public boolean isModelAvailableForResource(@Nonnull Resource resource);
+    public boolean isModelAvailableForResource(@NotNull Resource resource);
 
     /**
      * Determine is a model class is available for the request's resource's resource type.
@@ -96,7 +95,7 @@ public interface ModelFactory {
      * @param request a request
      * @return {@code true} if a model class is mapped to the resource type
      */
-    public boolean isModelAvailableForRequest(@Nonnull SlingHttpServletRequest request);
+    public boolean isModelAvailableForRequest(@NotNull SlingHttpServletRequest request);
 
     /**
      * Obtain an adapted model class based on the resource type of the provided resource.
@@ -110,7 +109,7 @@ public interface ModelFactory {
      * @throws ValidationException in case validation could not be performed for some reason (e.g. no validation information available)
      * @throws InvalidModelException in case the given model type could not be validated through the model validation
      */
-    public Object getModelFromResource(@Nonnull Resource resource) throws MissingElementsException,
+    public Object getModelFromResource(@NotNull Resource resource) throws MissingElementsException,
             InvalidAdaptableException, ModelClassException, PostConstructException, ValidationException, InvalidModelException;
 
     /**
@@ -125,7 +124,7 @@ public interface ModelFactory {
      * @throws ValidationException in case validation could not be performed for some reason (e.g. no validation information available)
      * @throws InvalidModelException in case the given model type could not be validated through the model validation
      */
-    public Object getModelFromRequest(@Nonnull SlingHttpServletRequest request) throws MissingElementsException,
+    public Object getModelFromRequest(@NotNull SlingHttpServletRequest request) throws MissingElementsException,
             InvalidAdaptableException, ModelClassException, PostConstructException, ValidationException, InvalidModelException;
 
     /**
@@ -197,5 +196,5 @@ public interface ModelFactory {
      * @param <T> the target adapter class
      * @return an instance of the target class or null if the adaptation could not be done
      */
-    public <T> T getModelFromWrappedRequest(@Nonnull SlingHttpServletRequest request, @Nonnull Resource resource, @Nonnull Class<T> targetClass);
+    public <T> T getModelFromWrappedRequest(@NotNull SlingHttpServletRequest request, @NotNull Resource resource, @NotNull Class<T> targetClass);
 }
diff --git a/src/main/java/org/apache/sling/models/factory/package-info.java b/src/main/java/org/apache/sling/models/factory/package-info.java
index 4467149..67bd42f 100644
--- a/src/main/java/org/apache/sling/models/factory/package-info.java
+++ b/src/main/java/org/apache/sling/models/factory/package-info.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("1.4.0")
+@Version("1.4.1")
 package org.apache.sling.models.factory;
 
-import aQute.bnd.annotation.Version;
\ No newline at end of file
+import aQute.bnd.annotation.Version;
diff --git a/src/main/java/org/apache/sling/models/spi/DisposalCallbackRegistry.java b/src/main/java/org/apache/sling/models/spi/DisposalCallbackRegistry.java
index 62f7d02..b3bc9c0 100644
--- a/src/main/java/org/apache/sling/models/spi/DisposalCallbackRegistry.java
+++ b/src/main/java/org/apache/sling/models/spi/DisposalCallbackRegistry.java
@@ -16,10 +16,10 @@
  */
 package org.apache.sling.models.spi;
 
-import javax.annotation.Nonnull;
-
 import aQute.bnd.annotation.ConsumerType;
 
+import org.jetbrains.annotations.NotNull;
+
 /**
  * Interface which allows for the registration of DisposalCallback listeners.
  * This interface should not be implemnted by clients.
@@ -32,6 +32,6 @@ public interface DisposalCallbackRegistry {
      * 
      * @param callback the callback to register
      */
-    void addDisposalCallback(@Nonnull DisposalCallback callback);
+    void addDisposalCallback(@NotNull DisposalCallback callback);
 
 }
diff --git a/src/main/java/org/apache/sling/models/spi/ImplementationPicker.java b/src/main/java/org/apache/sling/models/spi/ImplementationPicker.java
index 9eb2280..cdc2907 100644
--- a/src/main/java/org/apache/sling/models/spi/ImplementationPicker.java
+++ b/src/main/java/org/apache/sling/models/spi/ImplementationPicker.java
@@ -18,11 +18,11 @@
  */
 package org.apache.sling.models.spi;
 
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-
 import aQute.bnd.annotation.ConsumerType;
 
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
 /**
  * Defines a strategy to choose an implementation for a model if multiple are registered 
  * for the same interface or super class.
@@ -49,6 +49,6 @@ public interface ImplementationPicker {
      * @param adaptable For reference: the adaptable. May be enquired to detect the context of the adaption. Never null.
      * @return If an implementation is chosen the class is returned, otherwise null.
      */
-    @CheckForNull Class<?> pick(@Nonnull Class<?> adapterType, @Nonnull Class<?>[] implementationsTypes, @Nonnull Object adaptable);
+    @Nullable Class<?> pick(@NotNull Class<?> adapterType, @NotNull Class<?>[] implementationsTypes, @NotNull Object adaptable);
 
 }
diff --git a/src/main/java/org/apache/sling/models/spi/Injector.java b/src/main/java/org/apache/sling/models/spi/Injector.java
index 8bee8a0..e76f2e3 100644
--- a/src/main/java/org/apache/sling/models/spi/Injector.java
+++ b/src/main/java/org/apache/sling/models/spi/Injector.java
@@ -19,11 +19,11 @@ package org.apache.sling.models.spi;
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Type;
 
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-
 import aQute.bnd.annotation.ConsumerType;
 
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
 /**
  * Service interface for pluggable value injectors.
  */
@@ -35,7 +35,7 @@ public interface Injector {
      *
      * @return the injector's name
      */
-    @Nonnull String getName();
+    @NotNull String getName();
 
     /**
      * Produce a value for an injection point.
@@ -49,5 +49,5 @@ public interface Injector {
      *
      * @return the value to be injected or null if no value could be resolved
      */
-    @CheckForNull Object getValue(@Nonnull Object adaptable, String name, @Nonnull Type declaredType, @Nonnull AnnotatedElement element, @Nonnull DisposalCallbackRegistry callbackRegistry);
+    @Nullable Object getValue(@NotNull Object adaptable, String name, @NotNull Type declaredType, @NotNull AnnotatedElement element, @NotNull DisposalCallbackRegistry callbackRegistry);
 }
diff --git a/src/main/java/org/apache/sling/models/spi/ValuePreparer.java b/src/main/java/org/apache/sling/models/spi/ValuePreparer.java
index 842b7a8..bd3bb36 100644
--- a/src/main/java/org/apache/sling/models/spi/ValuePreparer.java
+++ b/src/main/java/org/apache/sling/models/spi/ValuePreparer.java
@@ -18,7 +18,7 @@ package org.apache.sling.models.spi;
 
 import aQute.bnd.annotation.ConsumerType;
 
-import javax.annotation.Nonnull;
+import org.jetbrains.annotations.NotNull;
 
 /**
  * Optimization interface for Injectors which wish to avoid repeated accessing of some object
@@ -34,5 +34,5 @@ public interface ValuePreparer {
      * @param adaptable the adaptable
      * @return a prepared value or ObjectUtils.NULL if a value is not preparable
      */
-    @Nonnull Object prepareValue(@Nonnull Object adaptable);
+    @NotNull Object prepareValue(@NotNull Object adaptable);
 }
diff --git a/src/main/java/org/apache/sling/models/spi/package-info.java b/src/main/java/org/apache/sling/models/spi/package-info.java
index 3c11005..54c57ce 100644
--- a/src/main/java/org/apache/sling/models/spi/package-info.java
+++ b/src/main/java/org/apache/sling/models/spi/package-info.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("1.2.0")
+@Version("1.2.1")
 package org.apache.sling.models.spi;
 
-import aQute.bnd.annotation.Version;
\ No newline at end of file
+import aQute.bnd.annotation.Version;