svn commit: r1858934 - /ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1858934 - /ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java

mthl
Author: mthl
Date: Wed May  8 17:11:35 2019
New Revision: 1858934

URL: http://svn.apache.org/viewvc?rev=1858934&view=rev
Log:
Improved: Rewrite ‘CustomPermissivePolicy#matchesEither’ static method
(OFBIZ-10187)

It now uses a lambda expression instead of an anonymous class.

Modified:
    ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java

Modified: ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java?rev=1858934&r1=1858933&r2=1858934&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java (original)
+++ ofbiz/ofbiz-framework/branches/release18.12/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java Wed May  8 17:11:35 2019
@@ -155,13 +155,15 @@ public class CustomPermissivePolicy impl
                     "picture", "source", "section", "nav", "footer")
             .toFactory();
 
-    private static Predicate<String> matchesEither(
-            final Pattern a, final Pattern b) {
-        return new Predicate<String>() {
-            public boolean apply(String s) {
-                return a.matcher(s).matches() || b.matcher(s).matches();
-            }
-        };
+    /**
+     * Constructs a predicate checking if a string matches any of the two provided patterns.
+     *
+     * @param a  the first pattern
+     * @param b  the second pattern
+     * @return a predicate checking if a string matches either {@code a} or {@code b}
+     */
+    private static Predicate<String> matchesEither(Pattern a, Pattern b) {
+        return str -> a.matcher(str).matches() || b.matcher(str).matches();
     }
 
     @Override