mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	【轻量级 PR】:fix: convertXxxByFlatMap, 当map后内容为null时, flatMap会出现NPE
Signed-off-by: dhb52 <dhb52@126.com>
This commit is contained in:
		| @@ -78,7 +78,7 @@ public class CollectionUtils { | ||||
|         if (CollUtil.isEmpty(from)) { | ||||
|             return new ArrayList<>(); | ||||
|         } | ||||
|         return from.stream().flatMap(func).filter(Objects::nonNull).collect(Collectors.toList()); | ||||
|         return from.stream().filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toList()); | ||||
|     } | ||||
|  | ||||
|     public static <T, U, R> List<R> convertListByFlatMap(Collection<T> from, | ||||
| @@ -87,7 +87,7 @@ public class CollectionUtils { | ||||
|         if (CollUtil.isEmpty(from)) { | ||||
|             return new ArrayList<>(); | ||||
|         } | ||||
|         return from.stream().map(mapper).flatMap(func).filter(Objects::nonNull).collect(Collectors.toList()); | ||||
|         return from.stream().map(mapper).filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toList()); | ||||
|     } | ||||
|  | ||||
|     public static <K, V> List<V> mergeValuesFromMap(Map<K, List<V>> map) { | ||||
| @@ -123,7 +123,7 @@ public class CollectionUtils { | ||||
|         if (CollUtil.isEmpty(from)) { | ||||
|             return new HashSet<>(); | ||||
|         } | ||||
|         return from.stream().flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet()); | ||||
|         return from.stream().filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet()); | ||||
|     } | ||||
|  | ||||
|     public static <T, U, R> Set<R> convertSetByFlatMap(Collection<T> from, | ||||
| @@ -132,7 +132,7 @@ public class CollectionUtils { | ||||
|         if (CollUtil.isEmpty(from)) { | ||||
|             return new HashSet<>(); | ||||
|         } | ||||
|         return from.stream().map(mapper).flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet()); | ||||
|         return from.stream().map(mapper).filter(Objects::nonNull).flatMap(func).filter(Objects::nonNull).collect(Collectors.toSet()); | ||||
|     } | ||||
|  | ||||
|     public static <T, K> Map<K, T> convertMap(Collection<T> from, Function<T, K> keyFunc) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 dhb52
					dhb52