DATACMNS-1383 - Parameters now properly detects Pageable and Sort extensions.

One of the constructors of Pageable wasn't properly checking for assignability of Pageable parameters to detect them but was expecting Pageable itself being used under all circumstances. This has now been opened up by an assignability check.
This commit is contained in:
Oliver Gierke
2018-08-30 15:40:41 +02:00
parent fc633f623d
commit 1d4a53dc28
2 changed files with 27 additions and 3 deletions

View File

@@ -68,6 +68,9 @@ public abstract class Parameters<S extends Parameters<S, T>, T extends Parameter
this.parameters = new ArrayList<>(types.size());
this.dynamicProjectionIndex = -1;
int pageableIndex = -1;
int sortIndex = -1;
for (int i = 0; i < types.size(); i++) {
MethodParameter methodParameter = new MethodParameter(method, i);
@@ -83,11 +86,19 @@ public abstract class Parameters<S extends Parameters<S, T>, T extends Parameter
this.dynamicProjectionIndex = parameter.getIndex();
}
if (Pageable.class.isAssignableFrom(parameter.getType())) {
pageableIndex = i;
}
if (Sort.class.isAssignableFrom(parameter.getType())) {
sortIndex = i;
}
parameters.add(parameter);
}
this.pageableIndex = types.indexOf(Pageable.class);
this.sortIndex = types.indexOf(Sort.class);
this.pageableIndex = pageableIndex;
this.sortIndex = sortIndex;
assertEitherAllParamAnnotatedOrNone();
}