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/causeway.git


The following commit(s) were added to refs/heads/master by this push:
     new 644f155cd1 CAUSEWAY-3809: commons internal: 
_NullSafe.streamAutodetect(Object)Can<T> to support Map traversal (convenience)
644f155cd1 is described below

commit 644f155cd1a841c62538fddff73c6c0edd5ee7b3
Author: Andi Huber <[email protected]>
AuthorDate: Wed Sep 4 16:26:11 2024 +0200

    CAUSEWAY-3809: commons internal:
    _NullSafe.streamAutodetect(Object)Can<T> to support Map traversal
    (convenience)
---
 .../org/apache/causeway/commons/internal/base/_NullSafe.java     | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git 
a/commons/src/main/java/org/apache/causeway/commons/internal/base/_NullSafe.java
 
b/commons/src/main/java/org/apache/causeway/commons/internal/base/_NullSafe.java
index e1fc7c7b09..6fb3ca0a98 100644
--- 
a/commons/src/main/java/org/apache/causeway/commons/internal/base/_NullSafe.java
+++ 
b/commons/src/main/java/org/apache/causeway/commons/internal/base/_NullSafe.java
@@ -184,6 +184,12 @@ public final class _NullSafe {
         };
     }
 
+    /**
+     * Returns a stream of elements contained by given pojo.
+     * Supports {@link Collection}, arrays, {@link Map}, etc.
+     * <p>
+     * In case of a {@link Map} traverses the map's values.
+     */
     public static Stream<?> streamAutodetect(final @Nullable Object pojo) {
         if(pojo==null) {
             return Stream.empty();
@@ -206,6 +212,9 @@ public final class _NullSafe {
             if(pojo instanceof long[]) return primitiveStream((long[]) pojo);
             if(pojo instanceof short[]) return primitiveStream((short[]) pojo);
         }
+        if(pojo instanceof Map) {
+            return ((Map<?, ?>)pojo).values().stream();
+        }
         if(pojo instanceof Iterable) {
             return stream((Iterable<?>)pojo);
         }

Reply via email to