Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 84f2fce

Browse files
committedMay 27, 2025
refactor: introduce two-args constructor to PageImpl
#3296 Signed-off-by: Attacktive <[email protected]>
1 parent 2760cb9 commit 84f2fce

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎src/main/java/org/springframework/data/domain/PageImpl.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,24 @@ public PageImpl(List<T> content, Pageable pageable, long total) {
5454
.orElse(total);
5555
}
5656

57+
/**
58+
* Creates a new {@link PageImpl} with the given content and pageable.
59+
*
60+
* @param content must not be {@literal null}.
61+
* @param pageable the paging information, must not be {@literal null}.
62+
*/
63+
public PageImpl(List<T> content, Pageable pageable) {
64+
this(content, pageable, CollectionUtils.isEmpty(content) ? 0 : content.size());
65+
}
66+
5767
/**
5868
* Creates a new {@link PageImpl} with the given content. This will result in the created {@link Page} being identical
5969
* to the entire {@link List}.
6070
*
6171
* @param content must not be {@literal null}.
6272
*/
6373
public PageImpl(List<T> content) {
64-
this(content, Pageable.unpaged(), CollectionUtils.isEmpty(content) ? 0 : content.size());
74+
this(content, Pageable.unpaged());
6575
}
6676

6777
@Override

0 commit comments

Comments
 (0)
Please sign in to comment.