From 247367871c9c5a1fd4a2b3b4b23e983c2f331ee2 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Wed, 8 May 2019 17:09:25 +0000 Subject: [PATCH] =?UTF-8?q?Improved:=20Rewrite=20=E2=80=98CustomPermissive?= =?UTF-8?q?Policy#matchesEither=E2=80=99=20static=20method=20(OFBIZ-10187)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It now uses a lambda expression instead of an anonymous class. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1858933 13f79535-47bb-0310-9956-ffa450edef68 --- .../ofbiz/base/html/CustomPermissivePolicy.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java b/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java index 60cfcf2bc5..607cfddf9c 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java @@ -155,13 +155,15 @@ public class CustomPermissivePolicy implements SanitizerCustomPolicy { "picture", "source", "section", "nav", "footer") .toFactory(); - private static Predicate matchesEither( - final Pattern a, final Pattern b) { - return new Predicate() { - 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 matchesEither(Pattern a, Pattern b) { + return str -> a.matcher(str).matches() || b.matcher(str).matches(); } @Override