|
22 | 22 |
|
23 | 23 | import org.springframework.beans.factory.annotation.Qualifier;
|
24 | 24 | import org.springframework.core.MethodParameter;
|
| 25 | +import org.springframework.core.annotation.MergedAnnotation; |
| 26 | +import org.springframework.core.annotation.MergedAnnotations; |
25 | 27 | import org.springframework.data.domain.PageRequest;
|
26 | 28 | import org.springframework.data.domain.Pageable;
|
27 | 29 | import org.springframework.data.domain.Sort;
|
|
39 | 41 | * @see PageableHandlerMethodArgumentResolver
|
40 | 42 | * @see ReactivePageableHandlerMethodArgumentResolver
|
41 | 43 | * @author Mark Paluch
|
| 44 | + * @author Vedran Pavic |
42 | 45 | */
|
43 | 46 | public abstract class PageableHandlerMethodArgumentResolverSupport {
|
44 | 47 |
|
@@ -228,10 +231,10 @@ protected String getParameterNameToUse(String source, @Nullable MethodParameter
|
228 | 231 |
|
229 | 232 | StringBuilder builder = new StringBuilder(prefix);
|
230 | 233 |
|
231 |
| - Qualifier qualifier = parameter == null ? null : parameter.getParameterAnnotation(Qualifier.class); |
| 234 | + String value = getQualifier(parameter); |
232 | 235 |
|
233 |
| - if (qualifier != null && StringUtils.hasLength(qualifier.value())) { |
234 |
| - builder.append(qualifier.value()); |
| 236 | + if (StringUtils.hasLength(value)) { |
| 237 | + builder.append(value); |
235 | 238 | builder.append(qualifierDelimiter);
|
236 | 239 | }
|
237 | 240 |
|
@@ -288,4 +291,17 @@ private Optional<Integer> parseAndApplyBoundaries(@Nullable String parameter, in
|
288 | 291 | return Optional.of(0);
|
289 | 292 | }
|
290 | 293 | }
|
| 294 | + |
| 295 | + @Nullable |
| 296 | + private static String getQualifier(@Nullable MethodParameter parameter) { |
| 297 | + |
| 298 | + if (parameter == null) { |
| 299 | + return null; |
| 300 | + } |
| 301 | + |
| 302 | + MergedAnnotations annotations = MergedAnnotations.from(parameter.getParameter()); |
| 303 | + MergedAnnotation<Qualifier> qualifier = annotations.get(Qualifier.class); |
| 304 | + |
| 305 | + return qualifier.isPresent() ? qualifier.getString("value") : null; |
| 306 | + } |
291 | 307 | }
|
0 commit comments