Introduce MoreLists.mappedCopy method
@@ -16,6 +16,7 @@ package com.facebook.presto.util;
import com.google.common.collect.ImmutableList;
import java.util.List;
+import java.util.function.Function;
import java.util.function.Predicate;
import static com.google.common.collect.ImmutableList.toImmutableList;
@@ -39,5 +40,14 @@ public class MoreLists
.collect(toImmutableList());
}
+ public static <T, R> List<R> mappedCopy(List<T> elements, Function<T, R> mapper)
+ {
+ requireNonNull(elements, "elements is null");
+ requireNonNull(mapper, "mapper is null");
+ return elements.stream()
+ .map(mapper)
+ .collect(toImmutableList());
+ }
+
private MoreLists() {}
}
