svn commit: r1859924 - in /ofbiz/ofbiz-framework/trunk/framework: base/src/main/java/org/apache/ofbiz/base/util/ base/src/main/java/org/apache/ofbiz/base/util/test/ widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/

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

svn commit: r1859924 - in /ofbiz/ofbiz-framework/trunk/framework: base/src/main/java/org/apache/ofbiz/base/util/ base/src/main/java/org/apache/ofbiz/base/util/test/ widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/

mthl
Author: mthl
Date: Sat May 25 09:17:12 2019
New Revision: 1859924

URL: http://svn.apache.org/viewvc?rev=1859924&view=rev
Log:
Improved: Inline ‘StringUtil#quoteStrList’ method
(OFBIZ-11014)

Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/StringUtilTests.java
    ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java?rev=1859924&r1=1859923&r2=1859924&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java Sat May 25 09:17:12 2019
@@ -140,21 +140,6 @@ public class StringUtil {
     }
 
     /**
-     * Encloses each of a List of Strings in quotes.
-     * @param list List of String(s) to quote.
-     */
-    public static List<String> quoteStrList(List<String> list) {
-        List<String> tmpList = list;
-
-        list = new LinkedList<>();
-        for (String str: tmpList) {
-            str = "'" + str + "'";
-            list.add(str);
-        }
-        return list;
-    }
-
-    /**
      * Creates a Map from an encoded name/value pair string
      * @param str The string to decode and format
      * @param delim the delimiter character(s) to join on (null will split on whitespace)

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/StringUtilTests.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/StringUtilTests.java?rev=1859924&r1=1859923&r2=1859924&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/StringUtilTests.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/test/StringUtilTests.java Sat May 25 09:17:12 2019
@@ -79,11 +79,6 @@ public class StringUtilTests extends Gen
         assertEquals("no-sep", list("1", "2", "3", "4", "5", "6"), StringUtil.split("1 2\t3\n4\r5\f6", null));
     }
 
-    public void testQuoteStrList() {
-        assertEquals("single", list("'1'"), StringUtil.quoteStrList(list("1")));
-        assertEquals("double", list("'1'", "'2'"), StringUtil.quoteStrList(list("1", "2")));
-    }
-
     public void testStrToMap() {
         assertNull("null-string", StringUtil.strToMap(null, false));
         assertEquals("missing =", Collections.emptyMap(), StringUtil.strToMap("1", false));

Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1859924&r1=1859923&r2=1859924&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java Sat May 25 09:17:12 2019
@@ -34,6 +34,7 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.UUID;
 import java.util.WeakHashMap;
+import java.util.stream.Collectors;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
@@ -1549,8 +1550,8 @@ public final class MacroFormRenderer imp
                 fieldNameList.add(childField.getName());
             }
         }
-        columnStyleList = StringUtil.quoteStrList(columnStyleList);
-        String columnStyleListString = StringUtil.join(columnStyleList, ", ");
+        String columnStyleListString =
+                columnStyleList.stream().map(str -> "'" + str + "'").collect(Collectors.joining(", "));
         StringWriter sr = new StringWriter();
         sr.append("<@renderFormatListWrapperOpen ");
         sr.append(" formName=\"");