Making the other two addAll methods return boolean on whether anything changes (somewhat related to COLLECTIONS-223)

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@956306 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2010-06-19 23:00:59 +00:00
parent ae77247f97
commit bcdca8e6c9
1 changed files with 8 additions and 5 deletions

View File

@ -804,11 +804,12 @@ public class CollectionUtils {
* @param enumeration the enumeration of elements to add, must not be null * @param enumeration the enumeration of elements to add, must not be null
* @throws NullPointerException if the collection or enumeration is null * @throws NullPointerException if the collection or enumeration is null
*/ */
//TODO return boolean or collection - check other add() methods too. public static <C> boolean addAll(Collection<C> collection, Enumeration<? extends C> enumeration) {
public static <C> void addAll(Collection<C> collection, Enumeration<? extends C> enumeration) { boolean changed = false;
while (enumeration.hasMoreElements()) { while (enumeration.hasMoreElements()) {
collection.add(enumeration.nextElement()); changed |= collection.add(enumeration.nextElement());
} }
return changed;
} }
/** /**
@ -821,10 +822,12 @@ public class CollectionUtils {
* @throws NullPointerException * @throws NullPointerException
* if the collection or array is null * if the collection or array is null
*/ */
public static <C> void addAll(Collection<C> collection, C[] elements) { public static <C> boolean addAll(Collection<C> collection, C[] elements) {
boolean changed = false;
for (int i = 0, size = elements.length; i < size; i++) { for (int i = 0, size = elements.length; i < size; i++) {
collection.add(elements[i]); changed |= collection.add(elements[i]);
} }
return changed;
} }
/** /**