1
1
/*
2
- * Copyright 2008-2014 the original author or authors.
2
+ * Copyright 2008-2017 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
15
15
*/
16
16
package org .springframework .data .domain ;
17
17
18
- import java .util .Optional ;
19
-
20
18
import org .springframework .data .domain .Sort .Direction ;
21
19
22
20
/**
23
21
* Basic Java Bean implementation of {@code Pageable}.
24
- *
22
+ *
25
23
* @author Oliver Gierke
26
24
* @author Thomas Darimont
27
25
*/
@@ -34,7 +32,7 @@ public class PageRequest extends AbstractPageRequest {
34
32
/**
35
33
* Creates a new {@link PageRequest}. Pages are zero indexed, thus providing 0 for {@code page} will return the first
36
34
* page.
37
- *
35
+ *
38
36
* @param page zero-based page index.
39
37
* @param size the size of the page to be returned.
40
38
* @deprecated use {@link #of(int, int)} instead.
@@ -46,7 +44,7 @@ public PageRequest(int page, int size) {
46
44
47
45
/**
48
46
* Creates a new {@link PageRequest} with sort parameters applied.
49
- *
47
+ *
50
48
* @param page zero-based page index.
51
49
* @param size the size of the page to be returned.
52
50
* @param direction the direction of the {@link Sort} to be specified, can be {@literal null}.
@@ -60,11 +58,11 @@ public PageRequest(int page, int size, Direction direction, String... properties
60
58
61
59
/**
62
60
* Creates a new {@link PageRequest} with sort parameters applied.
63
- *
61
+ *
64
62
* @param page zero-based page index.
65
63
* @param size the size of the page to be returned.
66
64
* @param sort can be {@literal null}.
67
- * @deprecated use {@link #of(int, int, Optional )} instead.
65
+ * @deprecated since 2.0, use {@link #of(int, int, Sort )} instead.
68
66
*/
69
67
@ Deprecated
70
68
public PageRequest (int page , int size , Sort sort ) {
@@ -74,14 +72,38 @@ public PageRequest(int page, int size, Sort sort) {
74
72
this .sort = sort ;
75
73
}
76
74
77
- public static PageRequest of (int page , int site ) {
78
- return of (page , site , Sort .unsorted ());
75
+ /**
76
+ * Creates a new unsorted {@link PageRequest}.
77
+ *
78
+ * @param page zero-based page index.
79
+ * @param size the size of the page to be returned.
80
+ * @since 2.0
81
+ */
82
+ public static PageRequest of (int page , int size ) {
83
+ return of (page , size , Sort .unsorted ());
79
84
}
80
85
81
- public static PageRequest of (int page , int site , Sort sort ) {
82
- return new PageRequest (page , site , sort );
86
+ /**
87
+ * Creates a new {@link PageRequest} with sort parameters applied.
88
+ *
89
+ * @param page zero-based page index.
90
+ * @param size the size of the page to be returned.
91
+ * @param sort must not be {@literal null}.
92
+ * @since 2.0
93
+ */
94
+ public static PageRequest of (int page , int size , Sort sort ) {
95
+ return new PageRequest (page , size , sort );
83
96
}
84
97
98
+ /**
99
+ * Creates a new {@link PageRequest} with sort direction and properties applied.
100
+ *
101
+ * @param page zero-based page index.
102
+ * @param size the size of the page to be returned.
103
+ * @param direction must not be {@literal null}.
104
+ * @param properties must not be {@literal null}.
105
+ * @since 2.0
106
+ */
85
107
public static PageRequest of (int page , int size , Direction direction , String ... properties ) {
86
108
return of (page , size , Sort .by (direction , properties ));
87
109
}
@@ -94,23 +116,23 @@ public Sort getSort() {
94
116
return sort ;
95
117
}
96
118
97
- /*
119
+ /*
98
120
* (non-Javadoc)
99
121
* @see org.springframework.data.domain.Pageable#next()
100
122
*/
101
123
public Pageable next () {
102
124
return new PageRequest (getPageNumber () + 1 , getPageSize (), getSort ());
103
125
}
104
126
105
- /*
127
+ /*
106
128
* (non-Javadoc)
107
129
* @see org.springframework.data.domain.AbstractPageRequest#previous()
108
130
*/
109
131
public PageRequest previous () {
110
132
return getPageNumber () == 0 ? this : new PageRequest (getPageNumber () - 1 , getPageSize (), getSort ());
111
133
}
112
134
113
- /*
135
+ /*
114
136
* (non-Javadoc)
115
137
* @see org.springframework.data.domain.Pageable#first()
116
138
*/
@@ -147,7 +169,7 @@ public int hashCode() {
147
169
return 31 * super .hashCode () + sort .hashCode ();
148
170
}
149
171
150
- /*
172
+ /*
151
173
* (non-Javadoc)
152
174
* @see java.lang.Object#toString()
153
175
*/
0 commit comments