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/07/08 13:33:24 UTC

[sling-org-apache-sling-testing-resourceresolver-mock] branch feature/nullability created (now 4c939b7)

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

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


      at 4c939b7  apply jetbrains nullability annotations on public API

This branch includes the following new commits:

     new 4c939b7  apply jetbrains nullability annotations on public API

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[sling-org-apache-sling-testing-resourceresolver-mock] 01/01: apply jetbrains nullability annotations on public API

Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4c939b7d9696c48951a67fcd7b6f6e9e35fa9289
Author: sseifert <ss...@pro-vision.de>
AuthorDate: Sun Jul 8 15:33:06 2018 +0200

    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
  */
-@org.osgi.annotation.versioning.Version("1.1")
+@org.osgi.annotation.versioning.Version("1.1.1")
 package org.apache.sling.testing.resourceresolver;