You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2010/10/19 03:38:58 UTC
svn commit: r1024084 -
/commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/TransformedCollection.java
Author: sebb
Date: Tue Oct 19 01:38:58 2010
New Revision: 1024084
URL: http://svn.apache.org/viewvc?rev=1024084&view=rev
Log:
generics
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/TransformedCollection.java
Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/TransformedCollection.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/TransformedCollection.java?rev=1024084&r1=1024083&r2=1024084&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/TransformedCollection.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/TransformedCollection.java Tue Oct 19 01:38:58 2010
@@ -76,11 +76,11 @@ public class TransformedCollection<E> ex
* @throws IllegalArgumentException if collection or transformer is null
* @since Commons Collections 3.3
*/
- // TODO: Generics
- public static Collection decorateTransform(Collection collection, Transformer transformer) {
- TransformedCollection decorated = new TransformedCollection(collection, transformer);
+ public static <E> Collection<E> decorateTransform(Collection<E> collection, Transformer<? super E, ? extends E> transformer) {
+ TransformedCollection<E> decorated = new TransformedCollection<E>(collection, transformer);
if (transformer != null && collection != null && collection.size() > 0) {
- Object[] values = collection.toArray();
+ @SuppressWarnings("unchecked") // collection is of type E
+ E[] values = (E[]) collection.toArray();
collection.clear();
for(int i=0; i<values.length; i++) {
decorated.decorated().add(transformer.transform(values[i]));