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

com.softicar.platform.common.container.collection.CollectionUtils Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy