Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-266

Wish for StringUtils.join(Collection, *)

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • 2.3
    • lang.*
    • None

    Description

      There is a lack of StringUtils.join(Collection, String) method in commons-lang. Could you please add it?

      Commons-lang has method join(Iterator, String), however join(Collection, String) is still useful. Join is used very often, and in most situations it is used with Collection, not with Iterator, because almost all methods return Collections, not Iterators and a lot of data is stored as Collections, not as Iterators. The string ".iterator()" has 11 characters while line for code is only 72 chars. I've found that in my code there are several methods that could be one line shorter if it was StringUtils.join(Collection, String). Compare:

      // with StringUtils.join(Collection, String)
      return "UNIQUE (" + StringUtils.join(unique.getColumnNames(), ", ") + ")";

      against:

      // without
      Iterator columnNames = unique.getColumnNames().iterator();
      return "UNIQUE (" + StringUtils.join(columnNames, ", ") + ")";

      Motivation is almost same as "Why we have StringUtils.join(Object[], String) while we could write StringUtils.join(Arrays.asList(array).iterator(), separator)?"

      Attachments

        Activity

          People

            Unassigned Unassigned
            yozh Stepan Koltsov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: