调整代码,避免滥用 Nonnull 注解。

This commit is contained in:
2023-04-21 01:47:18 +08:00
parent c6d3cbeaf5
commit 15a8b23ae3
5 changed files with 108 additions and 76 deletions

View File

@@ -18,7 +18,7 @@ package xyz.zhouxy.plusone.commons.util;
import java.util.List;
import javax.annotation.Nonnull;
import xyz.zhouxy.plusone.commons.annotation.StaticFactoryMethod;
/**
* 返回分页查询的结果
@@ -30,27 +30,25 @@ import javax.annotation.Nonnull;
*/
public class PageDTO<T> {
@Nonnull
private final Long total;
@Nonnull
private final long total;
private final List<T> content;
private PageDTO(@Nonnull List<T> content, @Nonnull Long total) {
private PageDTO(List<T> content, long total) {
Assert.isNotEmpty(content, "Content must not be null.");
this.content = content;
this.total = total;
}
@Nonnull
public static <T> PageDTO<T> of(@Nonnull List<T> content, @Nonnull Long total) {
@StaticFactoryMethod(PageDTO.class)
public static <T> PageDTO<T> of(List<T> content, long total) {
return new PageDTO<>(content, total);
}
@Nonnull
public Long getTotal() {
public long getTotal() {
return total;
}
@Nonnull
public List<T> getContent() {
return content;
}