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

sseifert pushed a commit to branch feature/SLING-7802-nullability
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-resourceresolver-mock.git

commit dafed2f86a1d30ef62e832dbfc5f34bbe81cbdbd
Author: sseifert <[email protected]>
AuthorDate: Sun Jul 8 15:33:06 2018 +0200

    SLING-7802 apply jetbrains nullability annotations on public API
---
 pom.xml                                                       |  9 +++++++++
 .../org/apache/sling/testing/resourceresolver/MockHelper.java | 11 +++++++----
 .../testing/resourceresolver/MockResourceResolverFactory.java |  3 ++-
 .../apache/sling/testing/resourceresolver/package-info.java   |  2 +-
 4 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/pom.xml b/pom.xml
index 5143a39..61a9adc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -85,6 +85,15 @@
             <version>2.5.3</version>
             <scope>compile</scope>
         </dependency>
+
+        <!-- Nullability annotations -->
+        <dependency>
+            <groupId>org.jetbrains</groupId>
+            <artifactId>annotations</artifactId>
+            <version>16.0.2</version>
+            <scope>provided</scope>
+        </dependency>
+
         <!-- testing -->
         <dependency>
             <groupId>junit</groupId>
diff --git 
a/src/main/java/org/apache/sling/testing/resourceresolver/MockHelper.java 
b/src/main/java/org/apache/sling/testing/resourceresolver/MockHelper.java
index 18508d8..f555586 100644
--- a/src/main/java/org/apache/sling/testing/resourceresolver/MockHelper.java
+++ b/src/main/java/org/apache/sling/testing/resourceresolver/MockHelper.java
@@ -26,6 +26,8 @@ import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Helper class to create resources:
@@ -52,7 +54,7 @@ public class MockHelper {
      * @param resolver Resource resolver
      * @return this
      */
-    public static MockHelper create(final ResourceResolver resolver) {
+    public static @NotNull MockHelper create(@NotNull final ResourceResolver 
resolver) {
         return new MockHelper(resolver);
     }
 
@@ -63,7 +65,7 @@ public class MockHelper {
      * @param path Resource path
      * @return this
      */
-    public MockHelper resource(final String path) {
+    public @NotNull MockHelper resource(@NotNull final String path) {
         final String fullPath;
         if ( path.startsWith("/") ) {
             fullPath = path;
@@ -87,7 +89,7 @@ public class MockHelper {
      * @param value Property value
      * @return this
      */
-    public MockHelper p(final String name, final Object value) {
+    public @NotNull MockHelper p(@NotNull final String name, @Nullable final 
Object value) {
         final Description d = this.stack.peek();
         d.properties.put(name, value);
 
@@ -98,6 +100,7 @@ public class MockHelper {
      * Finish building and add all resources to the resource tree.
      * @throws PersistenceException Persistence exception
      */
+    @SuppressWarnings("null")
     public void add() throws PersistenceException {
         for(int i=0; i<this.stack.size(); i++) {
             final Description d = this.stack.get(i);
@@ -115,7 +118,7 @@ public class MockHelper {
         this.resolver.commit();
     }
 
-    private void create(final String path, final Map<String, Object> 
properties) throws PersistenceException {
+    private void create(@NotNull final String path, @NotNull final Map<String, 
Object> properties) throws PersistenceException {
         final String parentPath = ResourceUtil.getParent(path);
         final String name = ResourceUtil.getName(path);
 
diff --git 
a/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
 
b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
index 8af9392..9b37d32 100644
--- 
a/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
+++ 
b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
@@ -26,6 +26,7 @@ import java.util.Stack;
 import org.apache.sling.api.resource.LoginException;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.jetbrains.annotations.NotNull;
 import org.osgi.service.event.EventAdmin;
 
 
@@ -119,7 +120,7 @@ public class MockResourceResolverFactory implements 
ResourceResolverFactory {
      * Make sure to remove it from the current thread context.
      * @param resolver Resource resolver
      */
-    public void closed(final ResourceResolver resolver) {
+    public void closed(@NotNull final ResourceResolver resolver) {
         final Stack<ResourceResolver> resolverStack = 
resolverStackHolder.get();
         if ( resolverStack != null ) {
             resolverStack.remove(resolver);
diff --git 
a/src/main/java/org/apache/sling/testing/resourceresolver/package-info.java 
b/src/main/java/org/apache/sling/testing/resourceresolver/package-info.java
index 93d082a..65cd956 100644
--- a/src/main/java/org/apache/sling/testing/resourceresolver/package-info.java
+++ b/src/main/java/org/apache/sling/testing/resourceresolver/package-info.java
@@ -19,5 +19,5 @@
 /**
  * Apache Sling Testing Resource Resolver Mock
  */
[email protected]("1.1")
[email protected]("1.1.1")
 package org.apache.sling.testing.resourceresolver;

Reply via email to