Predictable index position for BindingResult keys and parameter annotation convenience methods in MethodParameter

This commit is contained in:
Rossen Stoyanchev
2011-03-31 14:16:37 +00:00
parent 006cbb25c5
commit 3f11fbafaa
2 changed files with 18 additions and 4 deletions

View File

@@ -278,6 +278,20 @@ public class MethodParameter {
return null;
}
/**
* Return true if the parameter has at least one annotation, false if it has none.
*/
public boolean hasParameterAnnotations() {
return getParameterAnnotations().length != 0;
}
/**
* Return true if the parameter has the given annotation type, and false if it doesn't.
*/
public <T extends Annotation> boolean hasParameterAnnotation(Class<T> annotationType) {
return getParameterAnnotation(annotationType) != null;
}
/**
* Initialize parameter name discovery for this method parameter.
* <p>This method does not actually try to retrieve the parameter name at