/*
 * #%L
 * BroadleafCommerce Common Libraries
 * %%
 * Copyright (C) 2009 - 2013 Broadleaf Commerce
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package org.broadleafcommerce.common.util;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Transformer;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;


/**
 * Convenience methods for interacting with collections.
 * 
 * @author Andre Azzolini (apazzolini)
 */
public class BLCCollectionUtils {
    
    /**
     * Delegates to {@link CollectionUtils#collect(Collection, Transformer)}, but performs the necessary type coercion 
     * to allow the returned collection to be correctly casted based on the TypedTransformer.
     * 
     * @param inputCollection
     * @param transformer
     * @return the typed, collected Collection
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public static <T> Collection<T> collect(Collection inputCollection, TypedTransformer<T> transformer) {
        return CollectionUtils.collect(inputCollection, transformer);
    }

    @SuppressWarnings("rawtypes")
    public static <T> List<T> collectList(Collection inputCollection, TypedTransformer<T> transformer) {
        List<T> returnList = new ArrayList<T>();
        for (Object obj : inputCollection) {
            T transformed = transformer.transform(obj);
            returnList.add(transformed);
        }
        return returnList;
    }

    /**
     * Delegates to {@link CollectionUtils#select(Collection, org.apache.commons.collections.Predicate)}, but will
     * force the return type to be a List<T>.
     * 
     * @param inputCollection
     * @param predicate
     * @return
     */
    public static <T> List<T> selectList(Collection<T> inputCollection, TypedPredicate<T> predicate) {
        ArrayList<T> answer = new ArrayList<T>(inputCollection.size());
        CollectionUtils.select(inputCollection, predicate, answer);
        return answer;
    }

}

@@ -1623,24 +1623,202 @@
 er);%0A    %7D%0A%0A
+    /**%0A     * The same as %7B@link #collect(Collection, TypedTransformer)%7D but returns an ArrayList%0A     * @param inputCollection%0A     * @param transformer%0A     * @return%0A     */%0A
     @Suppres
@@ -2171,32 +2171,636 @@
 urnList;%0A    %7D%0A%0A
+    /**%0A     * The same as %7B@link #collect(Collection, TypedTransformer)%7D but returns an array%0A     * @param inputCollection%0A     * @param transformer%0A     * @return%0A     */%0A    @SuppressWarnings(%7B %22rawtypes%22, %22unchecked%22 %7D)%0A    public static %3CT%3E T%5B%5D collectArray(Collection inputCollection, TypedTransformer%3CT%3E transformer) %7B%0A        T%5B%5D returnArray = (T%5B%5D) new Object%5BinputCollection.size()%5D;%0A        int i = 0;%0A        for (Object obj : inputCollection) %7B%0A            T transformed = transformer.transform(obj);%0A            returnArray%5Bi++%5D = transformed;%0A        %7D%0A        return returnArray;%0A    %7D%0A%0A
     /**%0A     * D

Add collectArray method