You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Kiruahxh (Jira)" <ji...@apache.org> on 2020/08/10 08:16:00 UTC

[jira] [Created] (LANG-1594) Support lambda expressions in StringUtils.join

Kiruahxh created LANG-1594:
------------------------------

             Summary: Support lambda expressions in StringUtils.join
                 Key: LANG-1594
                 URL: https://issues.apache.org/jira/browse/LANG-1594
             Project: Commons Lang
          Issue Type: Improvement
          Components: lang.*
    Affects Versions: 3.11
            Reporter: Kiruahxh


It would be a nice addition to support lambda expressions in the StringUtils.join overloads, they are supported in java 8  so there should not be compatibility problems.

This would simplify this kind of code : 
{code:java}
List<ProductOutput> listProduct = new ArrayList<ProductOutput>();
...
String list = "";
int i = 0;
for (ProductOutput p : listProduct) {
    if (i != 0) {
        list += ",";
    }
    list += p.id;
    i++;
}
sql = "UPDATE xxx SET toto='tata' WHERE id IN (" + list + ")";
execUpdate(sql);{code}
Fixed version : 
{code:java}
List<ProductOutput> listProduct = new ArrayList<ProductOutput>();
...
String list = StringUtils.join(listProduct, ',', p -> String.valueOf(p.id))
sql = "UPDATE xxx SET toto='tata' WHERE id IN (" + list + ")";
execUpdate(sql);
{code}
 

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)