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:22:00 UTC
[jira] [Updated] (LANG-1594) Add support for lambda expressions in
StringUtils.join
[ https://issues.apache.org/jira/browse/LANG-1594?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kiruahxh updated LANG-1594:
---------------------------
Summary: Add support for lambda expressions in StringUtils.join (was: Support lambda expressions in StringUtils.join)
> Add support for 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
> Priority: Minor
>
> 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> productList = new ArrayList<Product>();
> ...
> String ids = "";
> int i = 0;
> for (Product p : productList) {
> if (i != 0) {
> ids += ",";
> }
> ids += p.id;
> i++;
> }
> String sql = "UPDATE product SET published=1 WHERE id IN (" + list + ")";
> execUpdate(sql);{code}
> Fixed version :
> {code:java}
> List<Product> productList = new ArrayList<Product>();
> ...
> String ids = StringUtils.join(productList, ',', p -> String.valueOf(p.id))
> String sql = "UPDATE product SET published=1 WHERE id IN (" + list + ")";
> execUpdate(sql);
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)