DATACMNS-520 - Fixed @Param validation in Parameters.

Parameters erroneously rejected @Param annotated query method parameters that were preceded by a non-bindable type (like Pageable or Sort) as it checked for a 0 index of the parameter. We now manually keep an index in the check itself and have removed the Parameter.isFirst() method as it's not used anywhere else.
This commit is contained in:
Oliver Gierke
2014-06-12 15:59:57 +02:00
parent 28b3221bcf
commit aa8d5987d9
3 changed files with 15 additions and 11 deletions

View File

@@ -50,15 +50,6 @@ public class Parameter {
this.parameter = parameter;
}
/**
* Returns whether the {@link Parameter} is the first one.
*
* @return
*/
boolean isFirst() {
return getIndex() == 0;
}
/**
* Returns whether the parameter is a special parameter.
*

View File

@@ -258,15 +258,18 @@ public abstract class Parameters<S extends Parameters<S, T>, T extends Parameter
private void assertEitherAllParamAnnotatedOrNone() {
boolean nameFound = false;
int index = 0;
for (T parameter : this.getBindableParameters()) {
if (parameter.isNamedParameter()) {
Assert.isTrue(nameFound || parameter.isFirst(), ALL_OR_NOTHING);
Assert.isTrue(nameFound || index == 0, ALL_OR_NOTHING);
nameFound = true;
} else {
Assert.isTrue(!nameFound, ALL_OR_NOTHING);
}
index++;
}
}