Polishing

This commit is contained in:
Juergen Hoeller
2015-09-08 18:11:30 +02:00
parent 5c22002d21
commit 52fdfd59ab
11 changed files with 44 additions and 43 deletions

View File

@@ -30,12 +30,12 @@ import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.util.Assert;
/**
* Response extractor that uses the given {@linkplain HttpMessageConverter entity
* converters} to convert the response into a type {@code T}.
* Response extractor that uses the given {@linkplain HttpMessageConverter entity converters}
* to convert the response into a type {@code T}.
*
* @author Arjen Poutsma
* @see RestTemplate
* @since 3.0
* @see RestTemplate
*/
public class HttpMessageConverterExtractor<T> implements ResponseExtractor<T> {
@@ -47,19 +47,18 @@ public class HttpMessageConverterExtractor<T> implements ResponseExtractor<T> {
private final Log logger;
/**
* Creates a new instance of the {@code HttpMessageConverterExtractor} with the given
* response type and message converters. The given converters must support the response
* type.
* Create a new instance of the {@code HttpMessageConverterExtractor} with the given response
* type and message converters. The given converters must support the response type.
*/
public HttpMessageConverterExtractor(Class<T> responseType, List<HttpMessageConverter<?>> messageConverters) {
this((Type) responseType, messageConverters);
}
/**
* Creates a new instance of the {@code HttpMessageConverterExtractor} with the given
* response type and message converters. The given converters must support the response
* type.
* Creates a new instance of the {@code HttpMessageConverterExtractor} with the given response
* type and message converters. The given converters must support the response type.
*/
public HttpMessageConverterExtractor(Type responseType, List<HttpMessageConverter<?>> messageConverters) {
this(responseType, messageConverters, LogFactory.getLog(HttpMessageConverterExtractor.class));
@@ -75,10 +74,10 @@ public class HttpMessageConverterExtractor<T> implements ResponseExtractor<T> {
this.logger = logger;
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public T extractData(ClientHttpResponse response) throws IOException {
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public T extractData(ClientHttpResponse response) throws IOException {
MessageBodyClientHttpResponseWrapper responseWrapper = new MessageBodyClientHttpResponseWrapper(response);
if (!responseWrapper.hasMessageBody() || responseWrapper.hasEmptyMessageBody()) {
return null;
@@ -106,9 +105,9 @@ public class HttpMessageConverterExtractor<T> implements ResponseExtractor<T> {
}
}
}
throw new RestClientException(
"Could not extract response: no suitable HttpMessageConverter found for response type [" +
this.responseType + "] and content type [" + contentType + "]");
throw new RestClientException("Could not extract response: no suitable HttpMessageConverter found " +
"for response type [" + this.responseType + "] and content type [" + contentType + "]");
}
private MediaType getContentType(ClientHttpResponse response) {