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
This commit is contained in:
parent
3745c67bd2
commit
2851806365
|
@ -969,17 +969,17 @@ public class StrBuilder implements CharSequence, Appendable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends each item in a collection to the builder without any separators.
|
* Appends each item in a iterable to the builder without any separators.
|
||||||
* Appending a null collection will have no effect.
|
* Appending a null iterable will have no effect.
|
||||||
* Each object is appended using {@link #append(Object)}.
|
* 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
|
* @return this, to enable chaining
|
||||||
* @since 2.3
|
* @since 2.3
|
||||||
*/
|
*/
|
||||||
public StrBuilder appendAll(Collection<?> coll) {
|
public StrBuilder appendAll(Iterable<?> iterable) {
|
||||||
if (coll != null && coll.size() > 0) {
|
if (iterable != null) {
|
||||||
Iterator<?> it = coll.iterator();
|
Iterator<?> it = iterable.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
append(it.next());
|
append(it.next());
|
||||||
}
|
}
|
||||||
|
@ -1029,19 +1029,19 @@ public class StrBuilder implements CharSequence, Appendable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
* 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)}.
|
* 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
|
* @param separator the separator to use, null means no separator
|
||||||
* @return this, to enable chaining
|
* @return this, to enable chaining
|
||||||
*/
|
*/
|
||||||
public StrBuilder appendWithSeparators(Collection<?> coll, String separator) {
|
public StrBuilder appendWithSeparators(Iterable<?> iterable, String separator) {
|
||||||
if (coll != null && coll.size() > 0) {
|
if (iterable != null) {
|
||||||
separator = (separator == null ? "" : separator);
|
separator = (separator == null ? "" : separator);
|
||||||
Iterator<?> it = coll.iterator();
|
Iterator<?> it = iterable.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
append(it.next());
|
append(it.next());
|
||||||
if (it.hasNext()) {
|
if (it.hasNext()) {
|
||||||
|
|
Loading…
Reference in New Issue