public static Class < ? > getParameterTypeOfRepeatedField ( Field field ) { Class < ? > componentType = null ; if ( isCollection ( field . getType ( ) ) ) { validateCollection ( field ) ; Type parameterType = getParameterType ( ( ParameterizedType ) field . getGenericType ( ) ) ; validateNestedParameterizedType ( parameterType ) ; componentType = ( Class < ? > ) parameterType ; } else if ( field . getType ( ) . isArray ( ) ) { componentType = field . getType ( ) . getComponentType ( ) ; return componentType ; } else { throw new IllegalArgumentException ( "Unsupported repeated type " + field . getType ( ) + " Allowed repeated fields are Collection<T> and arrays" ) ; } validateNestedRepeatedType ( componentType , field ) ; return componentType ; }
Returns type of the parameter or component type for the repeated field depending on whether it is a collection or an array .