@@ -406,6 +406,7 @@ public Class<?> getNestedParameterType() {
406406 Integer index = getTypeIndexForLevel (i );
407407 type = args [index != null ? index : args .length - 1 ];
408408 }
409+ // TODO: Object.class if unresolvable
409410 }
410411 if (type instanceof Class ) {
411412 return (Class <?>) type ;
@@ -462,6 +463,16 @@ public <A extends Annotation> A getMethodAnnotation(Class<A> annotationType) {
462463 return adaptAnnotation (getAnnotatedElement ().getAnnotation (annotationType ));
463464 }
464465
466+ /**
467+ * Return whether the method/constructor is annotated with the given type.
468+ * @param annotationType the annotation type to look for
469+ * @since 4.3
470+ * @see #getMethodAnnotation(Class)
471+ */
472+ public <A extends Annotation > boolean hasMethodAnnotation (Class <A > annotationType ) {
473+ return getAnnotatedElement ().isAnnotationPresent (annotationType );
474+ }
475+
465476 /**
466477 * Return the annotations associated with the specific method/constructor parameter.
467478 */
@@ -479,33 +490,37 @@ public Annotation[] getParameterAnnotations() {
479490 return this .parameterAnnotations ;
480491 }
481492
493+ /**
494+ * Return {@code true} if the parameter has at least one annotation,
495+ * {@code false} if it has none.
496+ * @see #getParameterAnnotations()
497+ */
498+ public boolean hasParameterAnnotations () {
499+ return (getParameterAnnotations ().length != 0 );
500+ }
501+
482502 /**
483503 * Return the parameter annotation of the given type, if available.
484504 * @param annotationType the annotation type to look for
485505 * @return the annotation object, or {@code null} if not found
486506 */
487507 @ SuppressWarnings ("unchecked" )
488- public <T extends Annotation > T getParameterAnnotation (Class <T > annotationType ) {
508+ public <A extends Annotation > A getParameterAnnotation (Class <A > annotationType ) {
489509 Annotation [] anns = getParameterAnnotations ();
490510 for (Annotation ann : anns ) {
491511 if (annotationType .isInstance (ann )) {
492- return (T ) ann ;
512+ return (A ) ann ;
493513 }
494514 }
495515 return null ;
496516 }
497517
498518 /**
499- * Return true if the parameter has at least one annotation, false if it has none.
500- */
501- public boolean hasParameterAnnotations () {
502- return (getParameterAnnotations ().length != 0 );
503- }
504-
505- /**
506- * Return true if the parameter has the given annotation type, and false if it doesn't.
519+ * Return whether the parameter is declared with the given annotation type.
520+ * @param annotationType the annotation type to look for
521+ * @see #getParameterAnnotation(Class)
507522 */
508- public <T extends Annotation > boolean hasParameterAnnotation (Class <T > annotationType ) {
523+ public <A extends Annotation > boolean hasParameterAnnotation (Class <A > annotationType ) {
509524 return (getParameterAnnotation (annotationType ) != null );
510525 }
511526
0 commit comments