com.softicar.platform.common.container.collection.CollectionUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.container.collection;
import java.util.Collection;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
/**
* Utility methods for {@link Collection}.
*
* @author Oliver Richers
*/
public class CollectionUtils {
/**
* Converts the values in the given input collection.
*
* @param input
* the input collection
* @param converter
* the converter function
* @param factory
* the target collection factory
* @return a new collection will all the converted values
*/
public static > C convert(Collection input, Function converter, Supplier factory) {
return input//
.stream()
.map(converter)
.collect(Collectors.toCollection(factory));
}
}