You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by sc...@apache.org on 2009/10/27 02:14:58 UTC

svn commit: r830042 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/StringUtils.java test/org/apache/commons/lang/StringUtilsTest.java

Author: scolebourne
Date: Tue Oct 27 01:14:57 2009
New Revision: 830042

URL: http://svn.apache.org/viewvc?rev=830042&view=rev
Log:
LANG-548 - Use Iterable instead of Collection

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java
    commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java?rev=830042&r1=830041&r2=830042&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java Tue Oct 27 01:14:57 2009
@@ -17,7 +17,6 @@
 package org.apache.commons.lang;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
@@ -3009,7 +3008,7 @@
     }
 
     /**
-     * <p>Joins the elements of the provided <code>Collection</code> into
+     * <p>Joins the elements of the provided <code>Iterable</code> into
      * a single String containing the provided elements.</p>
      *
      * <p>No delimiter is added before or after the list. Null objects or empty
@@ -3017,20 +3016,20 @@
      *
      * <p>See the examples here: {@link #join(Object[],char)}. </p>
      *
-     * @param collection  the <code>Collection</code> of values to join together, may be null
+     * @param iterable  the <code>Iterable</code> providing the values to join together, may be null
      * @param separator  the separator character to use
      * @return the joined String, <code>null</code> if null iterator input
      * @since 2.3
      */
-    public static String join(Collection<?> collection, char separator) {
-        if (collection == null) {
+    public static String join(Iterable<?> iterable, char separator) {
+        if (iterable == null) {
             return null;
         }
-        return join(collection.iterator(), separator);
+        return join(iterable.iterator(), separator);
     }
 
     /**
-     * <p>Joins the elements of the provided <code>Collection</code> into
+     * <p>Joins the elements of the provided <code>Iterable</code> into
      * a single String containing the provided elements.</p>
      *
      * <p>No delimiter is added before or after the list.
@@ -3038,16 +3037,16 @@
      *
      * <p>See the examples here: {@link #join(Object[],String)}. </p>
      *
-     * @param collection  the <code>Collection</code> of values to join together, may be null
+     * @param iterable  the <code>Iterable</code> providing the values to join together, may be null
      * @param separator  the separator character to use, null treated as ""
      * @return the joined String, <code>null</code> if null iterator input
      * @since 2.3
      */
-    public static String join(Collection<?> collection, String separator) {
-        if (collection == null) {
+    public static String join(Iterable<?> iterable, String separator) {
+        if (iterable == null) {
             return null;
         }
-        return join(collection.iterator(), separator);
+        return join(iterable.iterator(), separator);
     }
 
     // Delete

Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java?rev=830042&r1=830041&r2=830042&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java (original)
+++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java Tue Oct 27 01:14:57 2009
@@ -267,16 +267,16 @@
         assertEquals(TEXT_LIST, StringUtils.join(Arrays.asList(ARRAY_LIST).iterator(), SEPARATOR));
     }
 
-    public void testJoin_CollectionChar() {
-        assertEquals(null, StringUtils.join((Collection<?>) null, ','));
+    public void testJoin_IterableChar() {
+        assertEquals(null, StringUtils.join((Iterable<?>) null, ','));
         assertEquals(TEXT_LIST_CHAR, StringUtils.join(Arrays.asList(ARRAY_LIST), SEPARATOR_CHAR));
         assertEquals("", StringUtils.join(Arrays.asList(NULL_ARRAY_LIST), SEPARATOR_CHAR));
         assertEquals("", StringUtils.join(Arrays.asList(EMPTY_ARRAY_LIST), SEPARATOR_CHAR));
         assertEquals("foo", StringUtils.join(Collections.singleton("foo"), 'x'));
     }
 
-    public void testJoin_CollectionString() {
-        assertEquals(null, StringUtils.join((Collection<?>) null, null));
+    public void testJoin_IterableString() {
+        assertEquals(null, StringUtils.join((Iterable<?>) null, null));
         assertEquals(TEXT_LIST_NOSEP, StringUtils.join(Arrays.asList(ARRAY_LIST), null));
         assertEquals(TEXT_LIST_NOSEP, StringUtils.join(Arrays.asList(ARRAY_LIST), ""));
         assertEquals("foo", StringUtils.join(Collections.singleton("foo"), "x"));