DATACMNS-1058 - Polishing.

Improve Javadoc. Extend year range in license header.

Original pull request: #214.
This commit is contained in:
Mark Paluch
2017-05-11 09:19:06 +02:00
parent 0ff53bd5db
commit 7d496978f5
2 changed files with 44 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2014 the original author or authors.
* Copyright 2008-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,13 +15,11 @@
*/
package org.springframework.data.domain;
import java.util.Optional;
import org.springframework.data.domain.Sort.Direction;
/**
* Basic Java Bean implementation of {@code Pageable}.
*
*
* @author Oliver Gierke
* @author Thomas Darimont
*/
@@ -34,7 +32,7 @@ public class PageRequest extends AbstractPageRequest {
/**
* Creates a new {@link PageRequest}. Pages are zero indexed, thus providing 0 for {@code page} will return the first
* page.
*
*
* @param page zero-based page index.
* @param size the size of the page to be returned.
* @deprecated use {@link #of(int, int)} instead.
@@ -46,7 +44,7 @@ public class PageRequest extends AbstractPageRequest {
/**
* Creates a new {@link PageRequest} with sort parameters applied.
*
*
* @param page zero-based page index.
* @param size the size of the page to be returned.
* @param direction the direction of the {@link Sort} to be specified, can be {@literal null}.
@@ -60,11 +58,11 @@ public class PageRequest extends AbstractPageRequest {
/**
* Creates a new {@link PageRequest} with sort parameters applied.
*
*
* @param page zero-based page index.
* @param size the size of the page to be returned.
* @param sort can be {@literal null}.
* @deprecated use {@link #of(int, int, Optional)} instead.
* @deprecated since 2.0, use {@link #of(int, int, Sort)} instead.
*/
@Deprecated
public PageRequest(int page, int size, Sort sort) {
@@ -74,14 +72,38 @@ public class PageRequest extends AbstractPageRequest {
this.sort = sort;
}
public static PageRequest of(int page, int site) {
return of(page, site, Sort.unsorted());
/**
* Creates a new unsorted {@link PageRequest}.
*
* @param page zero-based page index.
* @param size the size of the page to be returned.
* @since 2.0
*/
public static PageRequest of(int page, int size) {
return of(page, size, Sort.unsorted());
}
public static PageRequest of(int page, int site, Sort sort) {
return new PageRequest(page, site, sort);
/**
* Creates a new {@link PageRequest} with sort parameters applied.
*
* @param page zero-based page index.
* @param size the size of the page to be returned.
* @param sort must not be {@literal null}.
* @since 2.0
*/
public static PageRequest of(int page, int size, Sort sort) {
return new PageRequest(page, size, sort);
}
/**
* Creates a new {@link PageRequest} with sort direction and properties applied.
*
* @param page zero-based page index.
* @param size the size of the page to be returned.
* @param direction must not be {@literal null}.
* @param properties must not be {@literal null}.
* @since 2.0
*/
public static PageRequest of(int page, int size, Direction direction, String... properties) {
return of(page, size, Sort.by(direction, properties));
}
@@ -94,7 +116,7 @@ public class PageRequest extends AbstractPageRequest {
return sort;
}
/*
/*
* (non-Javadoc)
* @see org.springframework.data.domain.Pageable#next()
*/
@@ -102,7 +124,7 @@ public class PageRequest extends AbstractPageRequest {
return new PageRequest(getPageNumber() + 1, getPageSize(), getSort());
}
/*
/*
* (non-Javadoc)
* @see org.springframework.data.domain.AbstractPageRequest#previous()
*/
@@ -110,7 +132,7 @@ public class PageRequest extends AbstractPageRequest {
return getPageNumber() == 0 ? this : new PageRequest(getPageNumber() - 1, getPageSize(), getSort());
}
/*
/*
* (non-Javadoc)
* @see org.springframework.data.domain.Pageable#first()
*/
@@ -147,7 +169,7 @@ public class PageRequest extends AbstractPageRequest {
return 31 * super.hashCode() + sort.hashCode();
}
/*
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
*/