From bcdca8e6c9930f0ab2b40f1b752bdaa00914ce22 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Sat, 19 Jun 2010 23:00:59 +0000 Subject: [PATCH] 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 --- .../apache/commons/collections/CollectionUtils.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/java/org/apache/commons/collections/CollectionUtils.java b/src/java/org/apache/commons/collections/CollectionUtils.java index 078202593..ce02226aa 100644 --- a/src/java/org/apache/commons/collections/CollectionUtils.java +++ b/src/java/org/apache/commons/collections/CollectionUtils.java @@ -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 void addAll(Collection collection, Enumeration enumeration) { + public static boolean addAll(Collection collection, Enumeration 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 void addAll(Collection collection, C[] elements) { + public static boolean addAll(Collection 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; } /**