diff --git a/src/main/java/org/apache/commons/collections4/CollectionUtils.java b/src/main/java/org/apache/commons/collections4/CollectionUtils.java index 14c7a27c8..7c0b9ffdc 100644 --- a/src/main/java/org/apache/commons/collections4/CollectionUtils.java +++ b/src/main/java/org/apache/commons/collections4/CollectionUtils.java @@ -995,9 +995,9 @@ public class CollectionUtils { * Partitions all elements from inputCollection into separate output collections, * based on the evaluation of the given predicate. *

- * For each predicate, the returned list will contain a collection holding - * all elements of the input collection matching the predicate. The last collection - * contained in the list will hold all elements which didn't match any predicate: + * For each predicate, the result will contain a list holding all elements of the + * input collection matching the predicate. The last list will hold all elements + * which didn't match any predicate: *

      *  [C1, R] = partition(I, P1) with
      *  I = input collection
@@ -1014,17 +1014,16 @@ public class CollectionUtils {
      * will result in the following output: [[1, 2], [3, 4, 5]].
      *
      * @param   the type of object the {@link Iterable} contains
-     * @param   the type of the output {@link Collection}
      * @param inputCollection  the collection to get the input from, may be null
      * @param predicate  the predicate to use, may be null
      * @return a list containing the output collections
      * @since 4.1
      */
-    public static > List partition(final Iterable inputCollection,
+    public static  List> partition(final Iterable inputCollection,
             final Predicate predicate) {
 
-        @SuppressWarnings("unchecked") // safe
-        final Factory factory = (Factory) FactoryUtils.instantiateFactory(ArrayList.class);
+        @SuppressWarnings({ "unchecked", "rawtypes" }) // safe
+        final Factory> factory = FactoryUtils.instantiateFactory((Class) ArrayList.class);
         @SuppressWarnings("unchecked") // safe
         final Predicate[] predicates = new Predicate[] { predicate };
         return partition(inputCollection, factory, predicates);
@@ -1074,9 +1073,9 @@ public class CollectionUtils {
      * Partitions all elements from inputCollection into separate output collections,
      * based on the evaluation of the given predicates.
      * 

- * For each predicate, the returned list will contain a collection holding - * all elements of the input collection matching the predicate. The last collection - * contained in the list will hold all elements which didn't match any predicate: + * For each predicate, the result will contain a list holding all elements of the + * input collection matching the predicate. The last list will hold all elements + * which didn't match any predicate: *

      *  [C1, C2, R] = partition(I, P1, P2) with
      *  I = input collection
@@ -1098,17 +1097,16 @@ public class CollectionUtils {
      * and [x < 5] will result in the following output: [[1, 2], [3, 4], [5]].
      *
      * @param   the type of object the {@link Iterable} contains
-     * @param   the type of the output {@link Collection}
      * @param inputCollection  the collection to get the input from, may be null
      * @param predicates  the predicates to use, may be null
      * @return a list containing the output collections
      * @since 4.1
      */
-    public static > List partition(final Iterable inputCollection,
+    public static  List> partition(final Iterable inputCollection,
             final Predicate... predicates) {
 
-        @SuppressWarnings("unchecked") // safe
-        final Factory factory = (Factory) FactoryUtils.instantiateFactory(ArrayList.class);
+        @SuppressWarnings({ "unchecked", "rawtypes" }) // safe
+        final Factory> factory = FactoryUtils.instantiateFactory((Class) ArrayList.class);
         return partition(inputCollection, factory, predicates);
     }
 
diff --git a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
index a9c7f741f..42ca30de1 100644
--- a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
@@ -1185,6 +1185,7 @@ public class CollectionUtilsTest extends MockTestCase {
         assertTrue(output1.contains(4L));
     }
 
+    @SuppressWarnings("unchecked")
     @Test
     public void partition() {
         List input = new ArrayList();
@@ -1192,7 +1193,7 @@ public class CollectionUtilsTest extends MockTestCase {
         input.add(2);
         input.add(3);
         input.add(4);
-        List> partitions = CollectionUtils.partition(input, EQUALS_TWO);
+        List> partitions = CollectionUtils.partition(input, EQUALS_TWO);
         assertEquals(2, partitions.size());
         
         // first partition contains 2
@@ -1248,7 +1249,8 @@ public class CollectionUtilsTest extends MockTestCase {
         input.add(2);
         input.add(3);
         input.add(4);
-        List> partitions = CollectionUtils.partition(input, EQUALS_TWO, EVEN);
+        @SuppressWarnings("unchecked")
+        List> partitions = CollectionUtils.partition(input, EQUALS_TWO, EVEN);
 
         // first partition contains 2
         Collection partition = partitions.get(0);