public static List < Parameter > collectConstructorParameters ( Class < ? > cls , Components components , javax . ws . rs . Consumes classConsumes ) { if ( cls . isLocalClass ( ) || ( cls . isMemberClass ( ) && ! Modifier . isStatic ( cls . getModifiers ( ) ) ) ) { return Collections . emptyList ( ) ; } List < Parameter > selected = Collections . emptyList ( ) ; int maxParamsCount = 0 ; for ( Constructor < ? > constructor : cls . getDeclaredConstructors ( ) ) { if ( ! ReflectionUtils . isConstructorCompatible ( constructor ) && ! ReflectionUtils . isInject ( Arrays . asList ( constructor . getDeclaredAnnotations ( ) ) ) ) { continue ; } final Type [ ] genericParameterTypes = constructor . getGenericParameterTypes ( ) ; final Annotation [ ] [ ] annotations = constructor . getParameterAnnotations ( ) ; int paramsCount = 0 ; final List < Parameter > parameters = new ArrayList < Parameter > ( ) ; for ( int i = 0 ; i < genericParameterTypes . length ; i ++ ) { final List < Annotation > tmpAnnotations = Arrays . asList ( annotations [ i ] ) ; if ( isContext ( tmpAnnotations ) ) { paramsCount ++ ; } else { final Type genericParameterType = genericParameterTypes [ i ] ; final List < Parameter > tmpParameters = collectParameters ( genericParameterType , tmpAnnotations , components , classConsumes ) ; if ( tmpParameters . size ( ) >= 1 ) { for ( Parameter tmpParameter : tmpParameters ) { if ( ParameterProcessor . applyAnnotations ( tmpParameter , genericParameterType , tmpAnnotations , components , classConsumes == null ? new String [ 0 ] : classConsumes . value ( ) , null ) != null ) { parameters . add ( tmpParameter ) ; } } paramsCount ++ ; } } } if ( paramsCount >= maxParamsCount ) { maxParamsCount = paramsCount ; selected = parameters ; } } return selected ; }
Collects constructor - level parameters from class .