You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/03/04 14:04:03 UTC
[isis] branch master updated: ISIS-1841 add transform to _Lists
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new ccc6014 ISIS-1841 add transform to _Lists
ccc6014 is described below
commit ccc601465d438068e3fce342c06955b04118fdbe
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Mar 4 15:03:59 2018 +0100
ISIS-1841 add transform to _Lists
---
.../org/apache/isis/applib/internal/collections/_Lists.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/core/applib/src/main/java/org/apache/isis/applib/internal/collections/_Lists.java b/core/applib/src/main/java/org/apache/isis/applib/internal/collections/_Lists.java
index 852e843..6bf8059 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/internal/collections/_Lists.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/internal/collections/_Lists.java
@@ -26,6 +26,7 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
+import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
@@ -113,6 +114,16 @@ public final class _Lists {
return new LinkedList<T>(collection);
}
- // --
+ // -- TRANSFORMATION
+
+ public static <T, R> List<R> transform(@Nullable List<T> input, Function<T, R> mapper) {
+ if(input==null) {
+ return Collections.emptyList();
+ }
+ Objects.requireNonNull(mapper);
+ return input.stream()
+ .map(mapper)
+ .collect(Collectors.toList());
+ }
}
--
To stop receiving notification emails like this one, please contact
ahuber@apache.org.