feat:增加默认值的写入

This commit is contained in:
wangyu 2021-09-30 21:44:44 +08:00
parent 76e8d1441d
commit c33cf2c38b
1 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package com.flyfish.framework.utils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.Collection;
import java.util.function.Function;
@ -15,6 +16,7 @@ public class StringHelper {
/**
* 获取对象的值
*
* @param obj 对象
* @return 结果
*/
@ -24,14 +26,15 @@ public class StringHelper {
/**
* 快速的join一个集合
*
* @param collection 集合
* @param mapper 映射
* @param <T> 泛型
* @param mapper 映射
* @param <T> 泛型
* @return 结果
*/
public static <T> String join(Collection<T> collection, Function<T, String> mapper) {
if (CollectionUtils.isNotEmpty(collection)) {
return collection.stream().map(mapper).collect(Collectors.joining(","));
return collection.stream().map(mapper).filter(StringUtils::isNoneBlank).collect(Collectors.joining(","));
}
return "";
}