com.firefly.utils.lang.CollectionTools Maven / Gradle / Ivy
package com.firefly.utils.lang;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public abstract class CollectionTools {
public static Map transform(Collection from, MultiReturnFunction function) {
if(from == null || from.size() == 0)
return null;
Map map = new HashMap();
for(T t : from) {
Pair pair = function.apply(t);
map.put(pair.first, pair.second);
}
return map;
}
public static List transform(Collection from, SingleReturnFunction function) {
if(from == null || from.size() == 0)
return null;
List collection = new ArrayList();
for(T t : from) {
collection.add(function.apply(t));
}
return collection;
}
}