增加 service 模板

This commit is contained in:
YunaiV
2021-02-06 21:18:43 +08:00
parent 763e20796b
commit 2210ed5cf8
10 changed files with 97 additions and 195 deletions

View File

@@ -86,6 +86,13 @@ public class CollectionUtils {
return !CollectionUtil.isEmpty(from) ? from.get(0) : null;
}
public static <T> T findFirst(List<T> from, Predicate<T> predicate) {
if (CollUtil.isEmpty(from)) {
return null;
}
return from.stream().filter(predicate).findFirst().orElse(null);
}
public static <T> void addIfNotNull(Collection<T> coll, T item) {
if (item == null) {
return;