空值校验

This commit is contained in:
2024-03-05 17:07:21 +08:00
parent c6744bc012
commit 2477e2171e

View File

@@ -1,5 +1,6 @@
package cn.ysk.cashier.utils;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -65,7 +66,6 @@ public class ListUtil {
public static List<String> stringChangeStringList(String listString){
// 使用Fastjson将JSON字符串转换为JSONArray对象
listString = listString.replaceAll("\"", "").replaceAll("\\[", "").replaceAll("\\]", "");
List<String> stringList = Stream.of(listString.split(","))
.map(String::trim)
@@ -75,8 +75,10 @@ public class ListUtil {
public static List<Integer> stringChangeIntegerList(String listString){
// 使用Fastjson将JSON字符串转换为JSONArray对象
listString = listString.replaceAll("\"", "").replaceAll("\\[", "").replaceAll("\\]", "");
if (StringUtils.isEmpty(listString)) {
return new ArrayList<>();
}
List<Integer> integerList = Stream.of(listString.split(","))
.map(Integer::valueOf)
.collect(Collectors.toList());