@ SuppressWarnings ( "unchecked" ) public < T > T parseInterface ( final Class < T > serviceInterface , FoxHttpClient foxHttpClient ) throws FoxHttpException { try { Method [ ] methods = serviceInterface . getDeclaredMethods ( ) ; for ( Method method : methods ) { FoxHttpMethodParser foxHttpMethodParser = new FoxHttpMethodParser ( ) ; foxHttpMethodParser . parseMethod ( method , foxHttpClient ) ; FoxHttpRequestBuilder foxHttpRequestBuilder = new FoxHttpRequestBuilder ( foxHttpMethodParser . getUrl ( ) , foxHttpMethodParser . getRequestType ( ) , foxHttpClient ) . setRequestHeader ( foxHttpMethodParser . getHeaderFields ( ) ) . setSkipResponseBody ( foxHttpMethodParser . isSkipResponseBody ( ) ) . setFollowRedirect ( foxHttpMethodParser . isFollowRedirect ( ) ) ; requestCache . put ( method , foxHttpRequestBuilder ) ; } return ( T ) Proxy . newProxyInstance ( serviceInterface . getClassLoader ( ) , new Class [ ] { serviceInterface } , new FoxHttpAnnotationInvocationHandler ( requestCache , responseParsers ) ) ; } catch ( FoxHttpException e ) { throw e ; } catch ( Exception e ) { throw new FoxHttpRequestException ( e ) ; } }
Parse the given interface for the use of FoxHttp