public static int getAnnotatedParameterIndex ( Method method , Class < ? extends Annotation > annotationClass ) { Annotation [ ] [ ] annotationsForParameters = method . getParameterAnnotations ( ) ; for ( int i = 0 ; i < annotationsForParameters . length ; i ++ ) { Annotation [ ] parameterAnnotations = annotationsForParameters [ i ] ; if ( hasAnnotation ( parameterAnnotations , annotationClass ) ) { return i ; } } return - 1 ; }
Returns index of the first parameter with matching annotationClass - 1 if no parameter found with the supplied annotation .