@@ -406,6 +406,7 @@ public Class<?> getNestedParameterType() {
406
406
Integer index = getTypeIndexForLevel (i );
407
407
type = args [index != null ? index : args .length - 1 ];
408
408
}
409
+ // TODO: Object.class if unresolvable
409
410
}
410
411
if (type instanceof Class ) {
411
412
return (Class <?>) type ;
@@ -462,6 +463,16 @@ public <A extends Annotation> A getMethodAnnotation(Class<A> annotationType) {
462
463
return adaptAnnotation (getAnnotatedElement ().getAnnotation (annotationType ));
463
464
}
464
465
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
+
465
476
/**
466
477
* Return the annotations associated with the specific method/constructor parameter.
467
478
*/
@@ -479,33 +490,37 @@ public Annotation[] getParameterAnnotations() {
479
490
return this .parameterAnnotations ;
480
491
}
481
492
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
+
482
502
/**
483
503
* Return the parameter annotation of the given type, if available.
484
504
* @param annotationType the annotation type to look for
485
505
* @return the annotation object, or {@code null} if not found
486
506
*/
487
507
@ SuppressWarnings ("unchecked" )
488
- public <T extends Annotation > T getParameterAnnotation (Class <T > annotationType ) {
508
+ public <A extends Annotation > A getParameterAnnotation (Class <A > annotationType ) {
489
509
Annotation [] anns = getParameterAnnotations ();
490
510
for (Annotation ann : anns ) {
491
511
if (annotationType .isInstance (ann )) {
492
- return (T ) ann ;
512
+ return (A ) ann ;
493
513
}
494
514
}
495
515
return null ;
496
516
}
497
517
498
518
/**
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)
507
522
*/
508
- public <T extends Annotation > boolean hasParameterAnnotation (Class <T > annotationType ) {
523
+ public <A extends Annotation > boolean hasParameterAnnotation (Class <A > annotationType ) {
509
524
return (getParameterAnnotation (annotationType ) != null );
510
525
}
511
526
0 commit comments