You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2010/06/20 01:01:00 UTC
svn commit: r956306 -
/commons/proper/collections/trunk/src/java/org/apache/commons/collections/CollectionUtils.java
Author: bayard
Date: Sat Jun 19 23:00:59 2010
New Revision: 956306
URL: http://svn.apache.org/viewvc?rev=956306&view=rev
Log:
Making the other two addAll methods return boolean on whether anything changes (somewhat related to COLLECTIONS-223)
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/CollectionUtils.java
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/CollectionUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/CollectionUtils.java?rev=956306&r1=956305&r2=956306&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/CollectionUtils.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/CollectionUtils.java Sat Jun 19 23:00:59 2010
@@ -804,11 +804,12 @@ public class CollectionUtils {
* @param enumeration the enumeration of elements to add, must not be null
* @throws NullPointerException if the collection or enumeration is null
*/
- //TODO return boolean or collection - check other add() methods too.
- public static <C> void addAll(Collection<C> collection, Enumeration<? extends C> enumeration) {
+ public static <C> boolean addAll(Collection<C> collection, Enumeration<? extends C> enumeration) {
+ boolean changed = false;
while (enumeration.hasMoreElements()) {
- collection.add(enumeration.nextElement());
+ changed |= collection.add(enumeration.nextElement());
}
+ return changed;
}
/**
@@ -821,10 +822,12 @@ public class CollectionUtils {
* @throws NullPointerException
* 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++) {
- collection.add(elements[i]);
+ changed |= collection.add(elements[i]);
}
+ return changed;
}
/**