}
if (Utils.getOffset(annotations) != null) {
offsetCheck(type);
processed = true;
}
final Named named = Utils.getNamed(annotations);
if (processed) {
if (named != null)
throw new SpecificationViolationException("@Named cannot be present on @Limit/@Offset param", method);
} else {
if (named == null) {
if (!names.isEmpty())
throw new SpecificationViolationException("You're not allowed to mix @Named and indexed params", method);
final int paramIndex = index + 1
- (limit ? 1 : 0)
- (offset ? 1 : 0);
final Class<?> expectedType = getExpectedType(paramIndex);
if (expectedType != null) {
final Class<?> actualType = getActualParameterType(type, false);
if (!expectedType.isAssignableFrom(actualType)) {
final String msg = String.format("Indexed parameter '%s' of type %s cannot be assigned to query parameter of type %s", paramIndex, actualType.getName(), expectedType.getName());
throw new SpecificationViolationException(msg, method);
}
}
indexed++;
} else {
if (indexed > 0)
throw new SpecificationViolationException("You're not allowed to mix @Named and indexed params", method);
final String name = named.value();
final Class<?> expectedType = getExpectedType(name);
if (expectedType != null) {
final Class<?> actualClass = getActualParameterType(type, true);
if (!Collection.class.isAssignableFrom(actualClass) && !expectedType.isAssignableFrom(actualClass)) {
final String msg = String.format("Named parameter '%s' of type %s cannot be assigned to query parameter of type %s", name, actualClass.getName(), expectedType.getName());