Example usage for org.springframework.core ParameterizedTypeReference getType

List of usage examples for org.springframework.core ParameterizedTypeReference getType

Introduction

In this page you can find the example usage for org.springframework.core ParameterizedTypeReference getType.

Prototype

public Type getType() 

Source Link

Usage

From source file:org.springframework.web.client.RestTemplate.java

public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
        ParameterizedTypeReference<T> responseType, Object... uriVariables) throws RestClientException {

    Type type = responseType.getType();
    HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, type);
    ResponseEntityResponseExtractor<T> responseExtractor = new ResponseEntityResponseExtractor<T>(type);
    return execute(url, method, requestCallback, responseExtractor, uriVariables);
}

From source file:org.springframework.web.client.RestTemplate.java

public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
        ParameterizedTypeReference<T> responseType, Map<String, ?> uriVariables) throws RestClientException {

    Type type = responseType.getType();
    HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, type);
    ResponseEntityResponseExtractor<T> responseExtractor = new ResponseEntityResponseExtractor<T>(type);
    return execute(url, method, requestCallback, responseExtractor, uriVariables);
}

From source file:org.springframework.web.client.RestTemplate.java

public <T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity,
        ParameterizedTypeReference<T> responseType) throws RestClientException {

    Type type = responseType.getType();
    HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, type);
    ResponseEntityResponseExtractor<T> responseExtractor = new ResponseEntityResponseExtractor<T>(type);
    return execute(url, method, requestCallback, responseExtractor);
}

From source file:projekat.rest_client.RestTemplateFactory.java

public <T> Response<T> executeRequest(String uri, Class<T> responseType, HttpMethod httpMethod)
        throws Exception {
    ParameterizedTypeReference get = types.get(responseType);
    String typeName = get.getType().getTypeName();
    System.out.println(typeName);
    ResponseEntity exchange = restTemplate.exchange(uri, httpMethod,
            new HttpEntity<>(createHeaders("marko", "marko")), types.get(responseType));
    if (exchange.getStatusCode().is2xxSuccessful()) {
        return (Response<T>) exchange.getBody();
    }/*  w ww  . j ava2  s  .  co m*/
    throw new Exception(exchange.getStatusCode().toString());
}