private List < Map < Class < ? extends Annotation > , ParameterInfo < ? > > > createParametersInfos ( Method method ) { if ( method . getParameterTypes ( ) . length <= 2 ) { return Collections . emptyList ( ) ; } List < Map < Class < ? extends Annotation > , ParameterInfo < ? > > > result = new ArrayList <> ( ) ; Type [ ] parameterTypes = method . getGenericParameterTypes ( ) ; Annotation [ ] [ ] parameterAnnotations = method . getParameterAnnotations ( ) ; for ( int i = 2 ; i < parameterAnnotations . length ; i ++ ) { Annotation [ ] annotations = parameterAnnotations [ i ] ; Map < Class < ? extends Annotation > , ParameterInfo < ? > > paramAnnotations = new IdentityHashMap <> ( ) ; for ( Annotation annotation : annotations ) { Class < ? extends Annotation > annotationType = annotation . annotationType ( ) ; ParameterInfo < ? > parameterInfo ; if ( PathParam . class . isAssignableFrom ( annotationType ) ) { parameterInfo = ParameterInfo . create ( annotation , ParamConvertUtils . createPathParamConverter ( parameterTypes [ i ] ) ) ; } else if ( QueryParam . class . isAssignableFrom ( annotationType ) ) { parameterInfo = ParameterInfo . create ( annotation , ParamConvertUtils . createQueryParamConverter ( parameterTypes [ i ] ) ) ; } else if ( HeaderParam . class . isAssignableFrom ( annotationType ) ) { parameterInfo = ParameterInfo . create ( annotation , ParamConvertUtils . createHeaderParamConverter ( parameterTypes [ i ] ) ) ; } else { parameterInfo = ParameterInfo . create ( annotation , null ) ; } paramAnnotations . put ( annotationType , parameterInfo ) ; } // Must have either @PathParam, @QueryParam or @HeaderParam, but not two or more. int presence = 0 ; for ( Class < ? extends Annotation > annotationClass : paramAnnotations . keySet ( ) ) { if ( SUPPORTED_PARAM_ANNOTATIONS . contains ( annotationClass ) ) { presence ++ ; } } if ( presence != 1 ) { throw new IllegalArgumentException ( String . format ( "Must have exactly one annotation from %s for parameter %d in method %s" , SUPPORTED_PARAM_ANNOTATIONS , i , method ) ) ; } result . add ( Collections . unmodifiableMap ( paramAnnotations ) ) ; } return Collections . unmodifiableList ( result ) ; }
Gathers all parameters annotations for the given method starting from the third parameter .