com.box.sdk.internal.utils.CollectionUtils Maven / Gradle / Ivy
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);
}
}