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
The following commit(s) were added to refs/heads/feature/SLING-7802-nullability
by this push:
new 0fed296 SLING-7802 update nullability annotations
0fed296 is described below
commit 0fed2966a94ee8580bfe3e0b52322e3c534249ff
Author: sseifert <[email protected]>
AuthorDate: Mon Aug 6 13:26:36 2018 +0200
SLING-7802 update nullability annotations
---
.../testing/resourceresolver/MockResourceResolver.java | 10 ++++++----
.../resourceresolver/MockResourceResolverFactory.java | 5 +++--
.../MockResourceResolverFactoryOptions.java | 15 ++++++++++-----
3 files changed, 19 insertions(+), 11 deletions(-)
diff --git
a/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
index f7f5dfb..f72fc7e 100644
---
a/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
+++
b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolver.java
@@ -44,6 +44,7 @@ import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.resource.ValueMap;
import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
public class MockResourceResolver extends SlingAdaptable implements
ResourceResolver {
@@ -326,27 +327,28 @@ public class MockResourceResolver extends SlingAdaptable
implements ResourceReso
@Override
public void commit() throws PersistenceException {
+ EventAdmin eventAdmin = this.options.getEventAdmin();
synchronized ( this.resources ) {
for(final String path : this.deletedResources ) {
- if ( this.resources.remove(path) != null &&
this.options.getEventAdmin() != null ) {
+ if ( this.resources.remove(path) != null && eventAdmin != null
) {
final Dictionary<String, Object> props = new
Hashtable<String, Object>();
props.put(SlingConstants.PROPERTY_PATH, path);
final Event e = new
Event(SlingConstants.TOPIC_RESOURCE_REMOVED, props);
- this.options.getEventAdmin().sendEvent(e);
+ eventAdmin.sendEvent(e);
}
this.temporaryResources.remove(path);
}
for(final String path : this.temporaryResources.keySet() ) {
final boolean changed = this.resources.containsKey(path);
this.resources.put(path, this.temporaryResources.get(path));
- if ( this.options.getEventAdmin() != null ) {
+ if ( eventAdmin != null ) {
final Dictionary<String, Object> props = new
Hashtable<String, Object>();
props.put(SlingConstants.PROPERTY_PATH, path);
if (
this.resources.get(path).get(ResourceResolver.PROPERTY_RESOURCE_TYPE) != null )
{
props.put(SlingConstants.PROPERTY_RESOURCE_TYPE,
this.resources.get(path).get(ResourceResolver.PROPERTY_RESOURCE_TYPE));
}
final Event e = new Event(changed ?
SlingConstants.TOPIC_RESOURCE_CHANGED : SlingConstants.TOPIC_RESOURCE_ADDED,
props);
- this.options.getEventAdmin().sendEvent(e);
+ eventAdmin.sendEvent(e);
}
}
}
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 9b37d32..227d4a9 100644
---
a/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
+++
b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactory.java
@@ -27,6 +27,7 @@ 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.jetbrains.annotations.Nullable;
import org.osgi.service.event.EventAdmin;
@@ -46,7 +47,7 @@ public class MockResourceResolverFactory implements
ResourceResolverFactory {
* Create a new resource resolver factory
* @param eventAdmin All resource events are sent to this event admin
*/
- public MockResourceResolverFactory(final EventAdmin eventAdmin) {
+ public MockResourceResolverFactory(@Nullable final EventAdmin eventAdmin) {
this(new
MockResourceResolverFactoryOptions().setEventAdmin(eventAdmin));
}
@@ -61,7 +62,7 @@ public class MockResourceResolverFactory implements
ResourceResolverFactory {
* Create a new resource resolver factory.
* @param options Options
*/
- public MockResourceResolverFactory(final
MockResourceResolverFactoryOptions options) {
+ public MockResourceResolverFactory(@NotNull final
MockResourceResolverFactoryOptions options) {
this.options = options;
Map<String, Object> props= new HashMap<String,Object>();
props.put(MockResource.JCR_PRIMARYTYPE, ROOT_PRIMARY_TYPE);
diff --git
a/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactoryOptions.java
b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactoryOptions.java
index d173953..6f1e634 100644
---
a/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactoryOptions.java
+++
b/src/main/java/org/apache/sling/testing/resourceresolver/MockResourceResolverFactoryOptions.java
@@ -18,6 +18,8 @@
*/
package org.apache.sling.testing.resourceresolver;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.osgi.service.event.EventAdmin;
/**
@@ -31,20 +33,22 @@ public class MockResourceResolverFactoryOptions {
private boolean mangleNamespacePrefixes;
- public EventAdmin getEventAdmin() {
+ public @Nullable EventAdmin getEventAdmin() {
return eventAdmin;
}
- public MockResourceResolverFactoryOptions setEventAdmin(EventAdmin
eventAdmin) {
+ public @NotNull MockResourceResolverFactoryOptions setEventAdmin(@Nullable
EventAdmin eventAdmin) {
this.eventAdmin = eventAdmin;
return this;
}
- public String[] getSearchPaths() {
+ @SuppressWarnings("null")
+ public @NotNull String @NotNull [] getSearchPaths() {
return searchPaths;
}
- public MockResourceResolverFactoryOptions setSearchPaths(String[]
searchPaths) {
+ @SuppressWarnings("null")
+ public @NotNull MockResourceResolverFactoryOptions setSearchPaths(@NotNull
String @Nullable [] searchPaths) {
if ( searchPaths == null ) {
searchPaths = new String[] {};
}
@@ -56,8 +60,9 @@ public class MockResourceResolverFactoryOptions {
return mangleNamespacePrefixes;
}
- public void setMangleNamespacePrefixes(boolean mangleNamespacePrefixes) {
+ public @NotNull MockResourceResolverFactoryOptions
setMangleNamespacePrefixes(boolean mangleNamespacePrefixes) {
this.mangleNamespacePrefixes = mangleNamespacePrefixes;
+ return this;
}
}