static void throwExceptionWhenMultipleMethodMatchesFound ( String helpInfo , Method [ ] methods ) { if ( methods == null || methods . length < 2 ) { throw new IllegalArgumentException ( "Internal error: throwExceptionWhenMultipleMethodMatchesFound needs at least two methods." ) ; } StringBuilder sb = new StringBuilder ( ) ; sb . append ( "Several matching methods found, please specify the " ) ; sb . append ( helpInfo ) ; sb . append ( " so that PowerMock can determine which method you're referring to.\n" ) ; sb . append ( "Matching methods in class " ) . append ( methods [ 0 ] . getDeclaringClass ( ) . getName ( ) ) . append ( " were:\n" ) ; for ( Method method : methods ) { sb . append ( method . getReturnType ( ) . getName ( ) ) . append ( " " ) ; sb . append ( method . getName ( ) ) . append ( "( " ) ; final Class < ? > [ ] parameterTypes = method . getParameterTypes ( ) ; for ( Class < ? > paramType : parameterTypes ) { sb . append ( paramType . getName ( ) ) . append ( ".class " ) ; } sb . append ( ")\n" ) ; } throw new TooManyMethodsFoundException ( sb . toString ( ) ) ; }
Throw exception when multiple method matches found .