构造 PageResult 时,如果 list 是 null,则自动转为空列表,不抛异常。

pull/2/head
ZhouXY108 2024-12-29 22:40:35 +08:00
parent 8a60f4db66
commit 8f588c25b5
1 changed files with 2 additions and 3 deletions

View File

@ -20,7 +20,7 @@ import java.util.Collections;
import java.util.List;
import xyz.zhouxy.plusone.commons.annotation.StaticFactoryMethod;
import xyz.zhouxy.plusone.commons.util.AssertTools;
import xyz.zhouxy.plusone.commons.collection.CollectionTools;
/**
*
@ -37,8 +37,7 @@ public class PageResult<T> {
private final List<T> content;
private PageResult(List<T> content, long total) {
AssertTools.checkNotNull(content, "Content must not be null.");
this.content = content;
this.content = CollectionTools.nullToEmptyList(content);
this.total = total;
}