commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Duncan Jones (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (LANG-1037) Join list of objects with different end separator
Date Thu, 11 Sep 2014 14:00:44 GMT

     [ https://issues.apache.org/jira/browse/LANG-1037?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Duncan Jones closed LANG-1037.
------------------------------
    Resolution: Won't Fix

Discussed on ML and have concluded this doesn't belong in lang. If we ever create a Commons
Text component, it might belong there.

> Join list of objects with different end separator
> -------------------------------------------------
>
>                 Key: LANG-1037
>                 URL: https://issues.apache.org/jira/browse/LANG-1037
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>            Reporter: Duncan Jones
>            Assignee: Duncan Jones
>            Priority: Minor
>             Fix For: Discussion
>
>
> A common programming challenge is joining a list with a different separator between the
final two items. For example, joining a list with {{", "}} as the primary separator but {{"
and "}} as the final separator. Take a look at [this Stack Overflow question|http://stackoverflow.com/q/8255077/474189]
to see just how awkward the current solutions are.
> I propose that we extend {{StringUtils}} with three additional methods:
> {code:java}
> public static String join(Iterable<?> iterable, String separator, String endSeparator)
> public static String join(Object[] array, String separator, String endSeparator)
> public static String join(Object[] array, String separator, String endSeparator, int
startIndex, int endIndex)
> {code}
> This could also be added to the other {{join}} methods for primitives, but I suspect
the primary use case will be strings and I don't suggest we pollute the class any further.
> Below shows the expected pseudo output using {{", "}} and {{" and "}}:
> {code}
> join(a) == a
> join(a,b) == a and b
> join(a,b,c) == a, b and c
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message