de.thksystems.util.collection.CollectionUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tkscommons Show documentation
Show all versions of tkscommons Show documentation
Commons for lang, crypto, dom, text, csv, reflection, parsing, xtreams...
/*
* tksCommons
*
* Author : Thomas Kuhlmann (ThK-Systems, http://www.thk-systems.de)
* License : LGPL (https://www.gnu.org/licenses/lgpl.html)
*/
package de.thksystems.util.collection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public final class CollectionUtils {
private CollectionUtils() {
}
/**
* Creates a new {@link ArrayList} with the given entries.
*
* If you need to use a {@link List} class different to {@link ArrayList}, please use {@link #createCollection(Class, Object...)}.
*/
@SafeVarargs
public static List createArrayList(T... entries) {
return addToCollection(new ArrayList(), entries);
}
/**
* Adds all entries to the given {@link Collection}.
*/
@SafeVarargs
public static > C addToCollection(C collection, T... entries) {
for (T entry : entries) {
collection.add(entry);
}
return collection;
}
}