|
@@ -15,6 +15,25 @@ public class CollectionUtil {
|
|
return ts;
|
|
return ts;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static <S, T> List<T> toList(Iterable<S> iterable, Function<S, T> conver) {
|
|
|
|
+ if (iterable == null) return null;
|
|
|
|
+ List<T> ts = new LinkedList<>();
|
|
|
|
+ for (S s : iterable){
|
|
|
|
+ ts.add(conver.apply(s));
|
|
|
|
+ }
|
|
|
|
+ return ts;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static <S, T> List<T> toList(List<S> list, Function<S, T> conver) {
|
|
|
|
+ if (list == null) return null;
|
|
|
|
+ List<T> ts = new LinkedList<>();
|
|
|
|
+ for (S s : list){
|
|
|
|
+ ts.add(conver.apply(s));
|
|
|
|
+ }
|
|
|
|
+ return ts;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
public static <K, V> Map<K, V> toMap(List<V> list, Function<V, K> keyFunc) {
|
|
public static <K, V> Map<K, V> toMap(List<V> list, Function<V, K> keyFunc) {
|
|
if (list == null) return null;
|
|
if (list == null) return null;
|
|
Map<K, V> map = new HashMap<K, V>();
|
|
Map<K, V> map = new HashMap<K, V>();
|