I changed the string to a constant.

pull/578/head
null 2023-10-12 05:06:54 +00:00
parent 5d645e1d3c
commit f576673dad
1 changed files with 9 additions and 4 deletions

View File

@ -91,6 +91,11 @@ public class Page<ITEM_T> {
private final long totalCount;
private final List<ITEM_T> items;
final String nonNullItemsString = "Required non-null items";
final String nonNegativeValueOfItems = "Required non-negative value of items before";
final String positiveValueOfPageSize = "Required positive value of page size";
final String nonNegativeValueOfTotalItems = "Required non-negative value of total items";
/**
* Creates a new page.
*
@ -104,13 +109,13 @@ public class Page<ITEM_T> {
* @throws IllegalArgumentException when {@code totalCount} is negative
*/
public Page(Collection<? extends ITEM_T> items, long itemsBefore, int pageSize, long totalCount) {
requireNonNull(items, "Required non-null items");
requireNonNull(items, nonNullItemsString);
this.items = new ArrayList<>(items);
checkArgument(itemsBefore >= 0, "Required non-negative value of items before");
checkArgument(itemsBefore >= 0, nonNegativeValueOfItems);
this.itemsBefore = itemsBefore;
checkArgument(pageSize > 0, "Required positive value of page size");
checkArgument(pageSize > 0, positiveValueOfPageSize);
this.pageSize = pageSize;
checkArgument(totalCount >= 0, "Required non-negative value of total items");
checkArgument(totalCount >= 0, nonNegativeValueOfTotalItems);
this.totalCount = totalCount;
}