DATACMNS-1581 - Tighten nullability constraints for Sort parameters in PageRequest factory methods.

We now explicitly rejects null values for the Sort parameters in the constructor of PageRequest to avoid the creation of invalid instances if the IDE validation of nullability constraints is not in use.
This commit is contained in:
Oliver Drotbohm
2019-09-25 13:29:30 +02:00
parent 74a26dd3fe
commit 221ad9353e
4 changed files with 27 additions and 5 deletions

View File

@@ -18,6 +18,7 @@ package org.springframework.data.querydsl;
import org.springframework.data.domain.AbstractPageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.util.Assert;
import com.querydsl.core.types.OrderSpecifier;
@@ -57,13 +58,16 @@ public class QPageRequest extends AbstractPageRequest {
/**
* Creates a new {@link QPageRequest} with sort parameters applied.
*
* @param page
* @param size
* @param sort
* @param page must not be negative.
* @param size must be greater or equal to 0.
* @param sort must not be {@literal null}.
*/
public QPageRequest(int page, int size, QSort sort) {
super(page, size);
Assert.notNull(sort, "QSort must not be null!");
this.sort = sort;
}