// If it can validate the parameter type, it's a post parse validator
} else if (validator.getValidatedType().isAssignableFrom(boxedParamType)) {
postParseValidators.add(validator);
// Otherwise, we can't validate with this validator
} else {
throw new RoutingException("Validator for field " + extractor.getFieldName() +
" validates type " + validator.getValidatedType() +
", which doesn't match extracted type " + extractor.getExtractedType() +
" or parameter type " + paramType);
}
}
}
// If we have pre parse validators, wrap our extractor in them
if (!preParseValidators.isEmpty()) {
extractor = new ValidatingArgumentExtractor(extractor, preParseValidators);
}
// Either the extractor extracts a type that matches the param type, or it's a
// String, and we can lookup a parser to parse it into the param type
if (!boxedParamType.isAssignableFrom(extractor.getExtractedType())) {
if (extractor.getFieldName() != null) {
if (String.class.isAssignableFrom(extractor.getExtractedType())) {
// Look up a parser for a single-valued parameter
ParamParser<?> parser = ParamParsers.getParamParser(paramType);
if (parser == null) {
throw new RoutingException("Can't find parameter parser for type "
+ extractor.getExtractedType() + " on field "
+ extractor.getFieldName());
} else {
extractor =
new ParsingArgumentExtractor(extractor, parser);
}
} else if (String[].class.isAssignableFrom(extractor.getExtractedType())) {
// Look up a parser for a multi-valued parameter
ArrayParamParser<?> parser = ParamParsers.getArrayParser(paramType);
if (parser == null) {
throw new RoutingException("Can't find parameter array parser for type "
+ extractor.getExtractedType() + " on field "
+ extractor.getFieldName());
} else {
extractor =
new ParsingArrayExtractor(extractor, parser);
}
} else {
throw new RoutingException("Extracted type " + extractor.getExtractedType()
+ " for field " + extractor.getFieldName()
+ " doesn't match parameter type " + paramType);
}
}
}