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

com.firefly.utils.lang.CollectionTools Maven / Gradle / Ivy

There is a newer version: 4.0.3.2
Show newest version
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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy