@ SuppressWarnings ( value = "unchecked cast" ) public < Result > Result call ( TDApiRequest apiRequest , Optional < String > apiKeyCache , final JavaType resultType ) throws TDClientException { try { byte [ ] content = submitRequest ( apiRequest , apiKeyCache , byteArrayContentHandler ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "response:\n{}" , new String ( content , StandardCharsets . UTF_8 ) ) ; } if ( resultType . getRawClass ( ) == String . class ) { return ( Result ) new String ( content , StandardCharsets . UTF_8 ) ; } else { return getJsonReader ( resultType ) . readValue ( content ) ; } } catch ( JsonMappingException e ) { logger . error ( "Jackson mapping error" , e ) ; throw new TDClientException ( INVALID_JSON_RESPONSE , e ) ; } catch ( IOException e ) { throw new TDClientException ( INVALID_JSON_RESPONSE , e ) ; } }
Submit an API request and bind the returned JSON data into an object of the given result jackson JavaType . For mapping it uses Jackson object mapper .