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

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


The following commit(s) were added to refs/heads/master by this push:
     new d5aabaf  SLING-9555 add constants for values of property 
"resource.change.types" (#22)
d5aabaf is described below

commit d5aabaf0acc8e66ce0b168b12f9485f2d5fd0db7
Author: Konrad Windszus <[email protected]>
AuthorDate: Tue Jun 30 16:15:02 2020 +0200

    SLING-9555 add constants for values of property "resource.change.types" 
(#22)
---
 pom.xml                                            | 19 ++++++--
 .../observation/ResourceChangeListener.java        | 34 +++++++++++++-
 .../observation/ResourceChangeListenerTest.java    | 54 ++++++++++++++++++++++
 3 files changed, 102 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index fbabce1..8e02cb7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling-bundle-parent</artifactId>
-        <version>35</version>
+        <version>39</version>
         <relativePath />
     </parent>
 
@@ -52,6 +52,7 @@
     <properties>
         <site.jira.version.id>12314252</site.jira.version.id>
         <sling.java.version>8</sling.java.version>
+        
<project.build.outputTimestamp>2019-10-02T08:04:00Z</project.build.outputTimestamp>
     </properties>
 
     <dependencies>
@@ -73,7 +74,6 @@
         <dependency>
             <groupId>org.jetbrains</groupId>
             <artifactId>annotations</artifactId>
-            <version>16.0.2</version>
             <scope>compile</scope>
         </dependency>
 
@@ -81,7 +81,6 @@
         <dependency>
             <groupId>javax.jcr</groupId>
             <artifactId>jcr</artifactId>
-            <version>2.0</version>
             <scope>provided</scope>
         </dependency>
 
@@ -131,6 +130,20 @@
     <build>
         <plugins>
             <plugin>
+                <groupId>biz.aQute.bnd</groupId>
+                <artifactId>bnd-baseline-maven-plugin</artifactId>
+                <configuration>
+                    <diffpackages>
+                        <!-- Temporarily don't baseline due to 
https://issues.apache.org/jira/browse/SLING-9555:
+                             Although it might be incompatible with consumers, 
baseline only suggests a minor version increase.
+                             We decided to go for a micro increase only as it 
is very unlikely that any consumer nor any providers will be broken.
+                          -->
+                        
<diffpackage>!org.apache.sling.api.resource.observation</diffpackage>
+                        <diffpackage>*</diffpackage>
+                    </diffpackages>
+                </configuration>
+             </plugin>
+            <plugin>
                 <groupId>org.apache.rat</groupId>
                 <artifactId>apache-rat-plugin</artifactId>
                 <configuration>
diff --git 
a/src/main/java/org/apache/sling/api/resource/observation/ResourceChangeListener.java
 
b/src/main/java/org/apache/sling/api/resource/observation/ResourceChangeListener.java
index 0d9a184..e2caf50 100644
--- 
a/src/main/java/org/apache/sling/api/resource/observation/ResourceChangeListener.java
+++ 
b/src/main/java/org/apache/sling/api/resource/observation/ResourceChangeListener.java
@@ -92,12 +92,42 @@ public interface ResourceChangeListener {
      * If this property is missing, added, removed and changed events for 
resources
      * and added and removed events for resource providers are reported.
      * If this property is invalid, the listener is ignored. The type of the 
property
-     * must either be String, or a String array. Valid values are the 
constants from
-     * {@link ResourceChange.ChangeType}.
+     * must either be String, or a String array. Valid values are the 
constants from this class
+     * whose names are starting with {@code CHANGE_}. They map to one of the 
values of {@link ResourceChange.ChangeType}.
      */
     String CHANGES = "resource.change.types";
 
     /**
+     * String constant for {@link ResourceChange.ChangeType#ADDED}.
+     * @since 1.3.0 (Sling API Bundle 2.23.0)
+     */
+    String CHANGE_ADDED = "ADDED";
+
+    /**
+     * String constant for {@link ResourceChange.ChangeType#REMOVED}.
+     * @since 1.3.0 (Sling API Bundle 2.23.0)
+     */
+    String CHANGE_REMOVED = "REMOVED";
+
+    /**
+     * String constant for {@link ResourceChange.ChangeType#CHANGED}.
+     * @since 1.3.0 (Sling API Bundle 2.23.0)
+     */
+    String CHANGE_CHANGED = "CHANGED";
+
+    /**
+     * String constant for {@link ResourceChange.ChangeType#PROVIDER_ADDED}.
+     * @since 1.3.0 (Sling API Bundle 2.23.0)
+     */
+    String CHANGE_PROVIDER_ADDED = "PROVIDER_ADDED";
+
+    /**
+     * String constant for {@link ResourceChange.ChangeType#PROVIDER_REMOVED}.
+     * @since 1.3.0 (Sling API Bundle 2.23.0)
+     */
+    String CHANGE_PROVIDER_REMOVED = "PROVIDER_REMOVED";
+
+    /**
      * An optional hint indicating to the underlying implementation that for
      * changes regarding properties (added/removed/changed) the listener
      * is only interested in those property names listed inhere.
diff --git 
a/src/test/java/org/apache/sling/api/resource/observation/ResourceChangeListenerTest.java
 
b/src/test/java/org/apache/sling/api/resource/observation/ResourceChangeListenerTest.java
new file mode 100644
index 0000000..90b810b
--- /dev/null
+++ 
b/src/test/java/org/apache/sling/api/resource/observation/ResourceChangeListenerTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.api.resource.observation;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ResourceChangeListenerTest {
+
+    private final static String CHANGE_CONSTANT_PREFIX = "CHANGE_";
+
+    @Test
+    public void testChangeConstants() throws IllegalArgumentException, 
IllegalAccessException {
+        Collection<Field> changeConstants = getChangeConstants();
+        for (Field changeConstant : changeConstants) {
+            
ResourceChange.ChangeType.valueOf((String)changeConstant.get(null));
+        }
+        Assert.assertEquals(ResourceChange.ChangeType.values().length, 
changeConstants.size());
+    }
+
+    static Collection<Field> getChangeConstants() {
+        Field[] declaredFields = 
ResourceChangeListener.class.getDeclaredFields();
+        List<Field> constantChangeFields = new ArrayList<Field>();
+        for (Field field : declaredFields) {
+            if (java.lang.reflect.Modifier.isStatic(field.getModifiers()) && 
java.lang.reflect.Modifier.isFinal(field.getModifiers())) {
+                if (field.getName().startsWith(CHANGE_CONSTANT_PREFIX)) {
+                    constantChangeFields.add(field);
+                }
+            }
+        }
+        return constantChangeFields;
+    }
+}

Reply via email to