All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.box.sdk.internal.utils.CollectionUtils Maven / Gradle / Ivy

There is a newer version: 4.11.1
Show newest version
package com.box.sdk.internal.utils;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

/**
 * {@link Collection} related utlities.
 */
public class CollectionUtils {

    /**
     * Only static members.
     */
    protected CollectionUtils() {
    }

    /**
     * Re-maps a provided collection.
     *
     * @param 
     *            type of result
     * @param 
     *            type of source
     * @param source
     *            for mapping
     * @param mapper
     *            element mapper
     * @return mapped source
     */
    public static  List map(Collection source,
            Mapper mapper) {
        List result = new LinkedList();
        for (T_Source element : source) {
            result.add(mapper.map(element));
        }
        return result;
    }

    /**
     * Contract for {@link Collection}-s mapping.
     *
     * @param 
     *            type of result
     * @param 
     *            type of source
     */
    public interface Mapper {

        /**
         * Maps a provided value.
         *
         * @param input
         *            for mapping
         * @return mapped value
         */
        T_Result map(T_Source input);

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy