class Defaults {

    public static BiFunction<HttpRequestBase, HttpResponse, JsonNode> toJson(ObjectMapper mapper) {
        return (request, response) -> {
            try (InputStream content = response.getEntity().getContent()) {
                JsonNode jsonNode = mapper.readTree(content);
                if (jsonNode == null) {
                    throw new IllegalArgumentException("Source should not be empty");
                }
                return jsonNode;
            } catch (Exception e) {
                throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e);
            } finally {
                request.releaseConnection();
            }
        };
    }

    private  Defaults();

}