|
15 | 15 | */
|
16 | 16 | package org.springframework.data.web;
|
17 | 17 |
|
| 18 | +import static org.springframework.data.web.SpringDataAnnotationUtils.*; |
| 19 | + |
18 | 20 | import java.beans.PropertyEditorSupport;
|
19 | 21 | import java.lang.annotation.Annotation;
|
20 |
| -import java.lang.reflect.Method; |
21 |
| -import java.util.HashSet; |
22 |
| -import java.util.Set; |
23 | 22 |
|
24 | 23 | import javax.servlet.ServletRequest;
|
25 | 24 |
|
@@ -131,7 +130,7 @@ private Pageable getDefaultFromAnnotationOrFallback(MethodParameter methodParame
|
131 | 130 | return new PageRequest(fallbackPagable.getPageNumber(), fallbackPagable.getPageSize(), fallbackPagable.getSort());
|
132 | 131 | }
|
133 | 132 |
|
134 |
| - private static Pageable getDefaultPageRequestFrom(PageableDefaults defaults) { |
| 133 | + static Pageable getDefaultPageRequestFrom(PageableDefaults defaults) { |
135 | 134 |
|
136 | 135 | // +1 is because we substract 1 later
|
137 | 136 | int defaultPageNumber = defaults.pageNumber() + 1;
|
@@ -162,94 +161,6 @@ private String getPrefix(MethodParameter parameter) {
|
162 | 161 | return prefix;
|
163 | 162 | }
|
164 | 163 |
|
165 |
| - /** |
166 |
| - * Asserts uniqueness of all {@link Pageable} parameters of the method of the given {@link MethodParameter}. |
167 |
| - * |
168 |
| - * @param parameter |
169 |
| - */ |
170 |
| - private void assertPageableUniqueness(MethodParameter parameter) { |
171 |
| - |
172 |
| - Method method = parameter.getMethod(); |
173 |
| - |
174 |
| - if (containsMoreThanOnePageableParameter(method)) { |
175 |
| - Annotation[][] annotations = method.getParameterAnnotations(); |
176 |
| - assertQualifiersFor(method.getParameterTypes(), annotations); |
177 |
| - } |
178 |
| - } |
179 |
| - |
180 |
| - /** |
181 |
| - * Returns whether the given {@link Method} has more than one {@link Pageable} parameter. |
182 |
| - * |
183 |
| - * @param method |
184 |
| - * @return |
185 |
| - */ |
186 |
| - private boolean containsMoreThanOnePageableParameter(Method method) { |
187 |
| - |
188 |
| - boolean pageableFound = false; |
189 |
| - |
190 |
| - for (Class<?> type : method.getParameterTypes()) { |
191 |
| - |
192 |
| - if (pageableFound && type.equals(Pageable.class)) { |
193 |
| - return true; |
194 |
| - } |
195 |
| - |
196 |
| - if (type.equals(Pageable.class)) { |
197 |
| - pageableFound = true; |
198 |
| - } |
199 |
| - } |
200 |
| - |
201 |
| - return false; |
202 |
| - } |
203 |
| - |
204 |
| - /** |
205 |
| - * Asserts that every {@link Pageable} parameter of the given parameters carries an {@link Qualifier} annotation to |
206 |
| - * distinguish them from each other. |
207 |
| - * |
208 |
| - * @param parameterTypes |
209 |
| - * @param annotations |
210 |
| - */ |
211 |
| - private void assertQualifiersFor(Class<?>[] parameterTypes, Annotation[][] annotations) { |
212 |
| - |
213 |
| - Set<String> values = new HashSet<String>(); |
214 |
| - |
215 |
| - for (int i = 0; i < annotations.length; i++) { |
216 |
| - |
217 |
| - if (Pageable.class.equals(parameterTypes[i])) { |
218 |
| - |
219 |
| - Qualifier qualifier = findAnnotation(annotations[i]); |
220 |
| - |
221 |
| - if (null == qualifier) { |
222 |
| - throw new IllegalStateException( |
223 |
| - "Ambiguous Pageable arguments in handler method. If you use multiple parameters of type Pageable you need to qualify them with @Qualifier"); |
224 |
| - } |
225 |
| - |
226 |
| - if (values.contains(qualifier.value())) { |
227 |
| - throw new IllegalStateException("Values of the user Qualifiers must be unique!"); |
228 |
| - } |
229 |
| - |
230 |
| - values.add(qualifier.value()); |
231 |
| - } |
232 |
| - } |
233 |
| - } |
234 |
| - |
235 |
| - /** |
236 |
| - * Returns a {@link Qualifier} annotation from the given array of {@link Annotation}s. Returns {@literal null} if the |
237 |
| - * array does not contain a {@link Qualifier} annotation. |
238 |
| - * |
239 |
| - * @param annotations |
240 |
| - * @return |
241 |
| - */ |
242 |
| - private Qualifier findAnnotation(Annotation[] annotations) { |
243 |
| - |
244 |
| - for (Annotation annotation : annotations) { |
245 |
| - if (annotation instanceof Qualifier) { |
246 |
| - return (Qualifier) annotation; |
247 |
| - } |
248 |
| - } |
249 |
| - |
250 |
| - return null; |
251 |
| - } |
252 |
| - |
253 | 164 | /**
|
254 | 165 | * {@link java.beans.PropertyEditor} to create {@link Sort} instances from textual representations. The implementation
|
255 | 166 | * interprets the string as a comma separated list where the first entry is the sort direction ( {@code asc},
|
|
0 commit comments