rombert commented on a change in pull request #7:
URL: 
https://github.com/apache/sling-org-apache-sling-installer-core/pull/7#discussion_r447007140



##########
File path: 
src/main/java/org/apache/sling/installer/api/provider/package-info.java
##########
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
[email protected]("1.0.0")
+package org.apache.sling.installer.api.provider;

Review comment:
       Have you considered making it part of the existing api package?

##########
File path: 
src/main/java/org/apache/sling/installer/api/provider/RunModeSupport.java
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.installer.api.provider;
+
+import java.util.Set;
+import java.util.regex.Pattern;
+
+public final class RunModeSupport {
+
+    private static final String OR_SEPARATOR = ",";
+    private static final String AND_SEPARATOR = ".";
+    private static final String NOT_PREFIX = "-";
+
+    private RunModeSupport() {
+        // not supposed to be instantiated
+    }
+
+    /**
+     * Checks if a given run mode string is satisfied by the given active run 
modes.
+     * A run mode string consists out of run modes and operators (AND = ".", 
OR = "," and NOT = "-")
+     * The run mode string follows the following grammar in EBNF:
+     * <pre><code>
+     * run mode string ::= disjunctions
+     * disjunctions ::= conjunctions { "," conjunctions }
+     * conjunctions ::= conjunction { '.' conjunction }
+     * conjunction ::= notrunmode | runmode
+     * notrunmode ::= '-' runmode
+     * </code></pre>
+     * 
+     * The operator order is first "-" (not), second "." (AND), last "," (OR).
+     * @param disjunctions the expected run mode string to check
+     * @param activeRunModes the run modes against which to check
+     * @return the number of matching run modes or 0 if no match. If multiple 
disjunctions match the one with the highest number of matching run modes is 
returned.
+     */
+    public static int getNumberOfMatchingRunmodesFromDisjunctions(String 
disjunctions, Set<String> activeRunModes) {

Review comment:
       Ack. I was about to suggest adding this logic to the 
`SlingSettingsService`, but on the other hand the way the file and JCR 
installer providers are set up would not make it easy.
   
   Have you considered other terms instead of 'disjunctions'? While the term 
disjunctions is correct, I think run mode spec is more intuitive, so maybe 
something like `getNumberOfMatchingRunmodeFromSpec` or maybe even 
`getBestRunmodeMatchCountFromSpec`. I don't terribly like long method names but 
not sure we can do better.
   
   Perhaps if we move some of the language to the class this becomes easier ... 
If the class would become `RunModeMatcher` and the method 
`getBestMatchCountFromSpec` this would be slightly shorter.
   
   (Bikeshedding and all and feel free to keep whatever name you prefer, but 
since I'm confused other may be as well).




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to