From 2851806365330332f42fdc56d610eb20c8233233 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Thu, 10 Dec 2009 12:28:50 +0000 Subject: [PATCH] Changing appendAll and appendWithSeparators methods to take Iterable instead of Collection. LANG-548 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@889236 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/lang3/text/StrBuilder.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/java/org/apache/commons/lang3/text/StrBuilder.java b/src/java/org/apache/commons/lang3/text/StrBuilder.java index 52ff59507..318b5aaaa 100644 --- a/src/java/org/apache/commons/lang3/text/StrBuilder.java +++ b/src/java/org/apache/commons/lang3/text/StrBuilder.java @@ -969,17 +969,17 @@ public StrBuilder appendAll(Object[] array) { } /** - * Appends each item in a collection to the builder without any separators. - * Appending a null collection will have no effect. + * Appends each item in a iterable to the builder without any separators. + * Appending a null iterable will have no effect. * Each object is appended using {@link #append(Object)}. * - * @param coll the collection to append + * @param iterable the iterable to append * @return this, to enable chaining * @since 2.3 */ - public StrBuilder appendAll(Collection coll) { - if (coll != null && coll.size() > 0) { - Iterator it = coll.iterator(); + public StrBuilder appendAll(Iterable iterable) { + if (iterable != null) { + Iterator it = iterable.iterator(); while (it.hasNext()) { append(it.next()); } @@ -1029,19 +1029,19 @@ public StrBuilder appendWithSeparators(Object[] array, String separator) { } /** - * Appends a collection placing separators between each value, but + * Appends a iterable placing separators between each value, but * not before the first or after the last. - * Appending a null collection will have no effect. + * Appending a null iterable will have no effect. * Each object is appended using {@link #append(Object)}. * - * @param coll the collection to append + * @param iterable the iterable to append * @param separator the separator to use, null means no separator * @return this, to enable chaining */ - public StrBuilder appendWithSeparators(Collection coll, String separator) { - if (coll != null && coll.size() > 0) { + public StrBuilder appendWithSeparators(Iterable iterable, String separator) { + if (iterable != null) { separator = (separator == null ? "" : separator); - Iterator it = coll.iterator(); + Iterator it = iterable.iterator(); while (it.hasNext()) { append(it.next()); if (it.hasNext()) {