update 简化 stream 代码写法 (java 16) xx.collect(Collectors.toList()) => xx.toList() ;

update 简化 instanceof 代码写法 (java 12) 直接在后面定义变量 ;
update 简化 switch 代码写法 (java 12) ;
This commit is contained in:
zlyx
2023-01-19 20:03:26 +08:00
parent afbc78b672
commit 57da2e33a6
11 changed files with 18 additions and 27 deletions

View File

@ -30,7 +30,7 @@ public class StreamUtils {
if (CollUtil.isEmpty(collection)) {
return CollUtil.newArrayList();
}
return collection.stream().filter(function).collect(Collectors.toList());
return collection.stream().filter(function).toList();
}
/**
@ -70,7 +70,7 @@ public class StreamUtils {
if (CollUtil.isEmpty(collection)) {
return CollUtil.newArrayList();
}
return collection.stream().sorted(comparing).collect(Collectors.toList());
return collection.stream().sorted(comparing).toList();
}
/**
@ -188,7 +188,7 @@ public class StreamUtils {
.stream()
.map(function)
.filter(Objects::nonNull)
.collect(Collectors.toList());
.toList();
}
/**