de.tototec.utils.jface.viewer.Util Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of de.tototec.utils.jface.viewer Show documentation
Show all versions of de.tototec.utils.jface.viewer Show documentation
Utility classes to work with SWT/JFace Viewer API
The newest version!
package de.tototec.utils.jface.viewer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Function;
public enum Util {
INSTANCE;
public static List map(final Iterable source, final Function super T, ? extends R> convert) {
final List result = (source instanceof Collection>) ? new ArrayList(((Collection>) source).size())
: new LinkedList();
for (final T t : source) {
result.add(convert.apply(t));
}
return result;
}
public static List map(final T[] source, final Function super T, ? extends R> convert) {
return map(Arrays.asList(source), convert);
}
}