Polishing
This commit is contained in:
@@ -348,7 +348,6 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
||||
|
||||
private final HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
|
||||
public DefaultBuilder(HttpStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
@@ -397,7 +396,6 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> build() {
|
||||
return new ResponseEntity<Void>(null, this.headers, this.status);
|
||||
|
||||
@@ -488,8 +488,9 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity,
|
||||
Class<T> responseType) throws RestClientException {
|
||||
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, Class<T> responseType)
|
||||
throws RestClientException {
|
||||
|
||||
Assert.notNull(requestEntity, "'requestEntity' must not be null");
|
||||
|
||||
RequestCallback requestCallback = httpEntityCallback(requestEntity, responseType);
|
||||
@@ -498,8 +499,9 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity,
|
||||
ParameterizedTypeReference<T> responseType) throws RestClientException {
|
||||
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)
|
||||
throws RestClientException {
|
||||
|
||||
Assert.notNull(requestEntity, "'requestEntity' must not be null");
|
||||
|
||||
Type type = responseType.getType();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -95,10 +95,10 @@ final class OpaqueUriComponents extends UriComponents {
|
||||
|
||||
@Override
|
||||
protected UriComponents expandInternal(UriTemplateVariables uriVariables) {
|
||||
String expandedScheme = expandUriComponent(this.getScheme(), uriVariables);
|
||||
String expandedSSp = expandUriComponent(this.ssp, uriVariables);
|
||||
String expandedFragment = expandUriComponent(this.getFragment(), uriVariables);
|
||||
return new OpaqueUriComponents(expandedScheme, expandedSSp, expandedFragment);
|
||||
String expandedScheme = expandUriComponent(getScheme(), uriVariables);
|
||||
String expandedSsp = expandUriComponent(getSchemeSpecificPart(), uriVariables);
|
||||
String expandedFragment = expandUriComponent(getFragment(), uriVariables);
|
||||
return new OpaqueUriComponents(expandedScheme, expandedSsp, expandedFragment);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -252,7 +252,6 @@ public abstract class UriComponents implements Serializable {
|
||||
* Get the value for the given URI variable name.
|
||||
* If the value is {@code null}, an empty String is expanded.
|
||||
* If the value is {@link #SKIP_VALUE}, the URI variable is not expanded.
|
||||
*
|
||||
* @param name the variable name
|
||||
* @return the variable value, possibly {@code null} or {@link #SKIP_VALUE}
|
||||
*/
|
||||
@@ -295,8 +294,7 @@ public abstract class UriComponents implements Serializable {
|
||||
@Override
|
||||
public Object getValue(String name) {
|
||||
if (!this.valueIterator.hasNext()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Not enough variable values available to expand '" + name + "'");
|
||||
throw new IllegalArgumentException("Not enough variable values available to expand '" + name + "'");
|
||||
}
|
||||
return this.valueIterator.next();
|
||||
}
|
||||
|
||||
@@ -163,20 +163,20 @@ public class UriComponentsBuilder {
|
||||
*/
|
||||
public static UriComponentsBuilder fromUriString(String uri) {
|
||||
Assert.hasLength(uri, "'uri' must not be empty");
|
||||
Matcher m = URI_PATTERN.matcher(uri);
|
||||
if (m.matches()) {
|
||||
Matcher matcher = URI_PATTERN.matcher(uri);
|
||||
if (matcher.matches()) {
|
||||
UriComponentsBuilder builder = new UriComponentsBuilder();
|
||||
String scheme = m.group(2);
|
||||
String userInfo = m.group(5);
|
||||
String host = m.group(6);
|
||||
String port = m.group(8);
|
||||
String path = m.group(9);
|
||||
String query = m.group(11);
|
||||
String fragment = m.group(13);
|
||||
String scheme = matcher.group(2);
|
||||
String userInfo = matcher.group(5);
|
||||
String host = matcher.group(6);
|
||||
String port = matcher.group(8);
|
||||
String path = matcher.group(9);
|
||||
String query = matcher.group(11);
|
||||
String fragment = matcher.group(13);
|
||||
boolean opaque = false;
|
||||
if (StringUtils.hasLength(scheme)) {
|
||||
String s = uri.substring(scheme.length());
|
||||
if (!s.startsWith(":/")) {
|
||||
String rest = uri.substring(scheme.length());
|
||||
if (!rest.startsWith(":/")) {
|
||||
opaque = true;
|
||||
}
|
||||
}
|
||||
@@ -223,25 +223,23 @@ public class UriComponentsBuilder {
|
||||
*/
|
||||
public static UriComponentsBuilder fromHttpUrl(String httpUrl) {
|
||||
Assert.notNull(httpUrl, "'httpUrl' must not be null");
|
||||
Matcher m = HTTP_URL_PATTERN.matcher(httpUrl);
|
||||
if (m.matches()) {
|
||||
Matcher matcher = HTTP_URL_PATTERN.matcher(httpUrl);
|
||||
if (matcher.matches()) {
|
||||
UriComponentsBuilder builder = new UriComponentsBuilder();
|
||||
|
||||
String scheme = m.group(1);
|
||||
builder.scheme((scheme != null) ? scheme.toLowerCase() : scheme);
|
||||
builder.userInfo(m.group(4));
|
||||
String host = m.group(5);
|
||||
String scheme = matcher.group(1);
|
||||
builder.scheme(scheme != null ? scheme.toLowerCase() : null);
|
||||
builder.userInfo(matcher.group(4));
|
||||
String host = matcher.group(5);
|
||||
if (StringUtils.hasLength(scheme) && !StringUtils.hasLength(host)) {
|
||||
throw new IllegalArgumentException("[" + httpUrl + "] is not a valid HTTP URL");
|
||||
}
|
||||
builder.host(host);
|
||||
String port = m.group(7);
|
||||
String port = matcher.group(7);
|
||||
if (StringUtils.hasLength(port)) {
|
||||
builder.port(port);
|
||||
}
|
||||
builder.path(m.group(8));
|
||||
builder.query(m.group(10));
|
||||
|
||||
builder.path(matcher.group(8));
|
||||
builder.query(matcher.group(10));
|
||||
return builder;
|
||||
}
|
||||
else {
|
||||
@@ -264,7 +262,7 @@ public class UriComponentsBuilder {
|
||||
* Build a {@code UriComponents} instance from the various components
|
||||
* contained in this builder.
|
||||
* @param encoded whether all the components set in this builder are
|
||||
* encoded ({@code true}) or not ({@code false}).
|
||||
* encoded ({@code true}) or not ({@code false})
|
||||
* @return the URI components
|
||||
*/
|
||||
public UriComponents build(boolean encoded) {
|
||||
@@ -533,13 +531,12 @@ public class UriComponentsBuilder {
|
||||
*/
|
||||
public UriComponentsBuilder query(String query) {
|
||||
if (query != null) {
|
||||
Matcher m = QUERY_PARAM_PATTERN.matcher(query);
|
||||
while (m.find()) {
|
||||
String name = m.group(1);
|
||||
String eq = m.group(2);
|
||||
String value = m.group(3);
|
||||
queryParam(name, (value != null ? value :
|
||||
(StringUtils.hasLength(eq) ? "" : null)));
|
||||
Matcher matcher = QUERY_PARAM_PATTERN.matcher(query);
|
||||
while (matcher.find()) {
|
||||
String name = matcher.group(1);
|
||||
String eq = matcher.group(2);
|
||||
String value = matcher.group(3);
|
||||
queryParam(name, (value != null ? value : (StringUtils.hasLength(eq) ? "" : null)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -574,7 +571,7 @@ public class UriComponentsBuilder {
|
||||
Assert.notNull(name, "'name' must not be null");
|
||||
if (!ObjectUtils.isEmpty(values)) {
|
||||
for (Object value : values) {
|
||||
String valueAsString = value != null ? value.toString() : null;
|
||||
String valueAsString = (value != null ? value.toString() : null);
|
||||
this.queryParams.add(name, valueAsString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class UriTemplate implements Serializable {
|
||||
* or if it does not contain values for all the variable names
|
||||
*/
|
||||
public URI expand(Map<String, ?> uriVariables) {
|
||||
UriComponents expandedComponents = uriComponents.expand(uriVariables);
|
||||
UriComponents expandedComponents = this.uriComponents.expand(uriVariables);
|
||||
UriComponents encodedComponents = expandedComponents.encode();
|
||||
return encodedComponents.toUri();
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class UriTemplate implements Serializable {
|
||||
* or if it does not contain sufficient variables
|
||||
*/
|
||||
public URI expand(Object... uriVariableValues) {
|
||||
UriComponents expandedComponents = uriComponents.expand(uriVariableValues);
|
||||
UriComponents expandedComponents = this.uriComponents.expand(uriVariableValues);
|
||||
UriComponents encodedComponents = expandedComponents.encode();
|
||||
return encodedComponents.toUri();
|
||||
}
|
||||
@@ -177,11 +177,11 @@ public class UriTemplate implements Serializable {
|
||||
|
||||
private Parser(String uriTemplate) {
|
||||
Assert.hasText(uriTemplate, "'uriTemplate' must not be null");
|
||||
Matcher m = NAMES_PATTERN.matcher(uriTemplate);
|
||||
Matcher matcher = NAMES_PATTERN.matcher(uriTemplate);
|
||||
int end = 0;
|
||||
while (m.find()) {
|
||||
this.patternBuilder.append(quote(uriTemplate, end, m.start()));
|
||||
String match = m.group(1);
|
||||
while (matcher.find()) {
|
||||
this.patternBuilder.append(quote(uriTemplate, end, matcher.start()));
|
||||
String match = matcher.group(1);
|
||||
int colonIdx = match.indexOf(':');
|
||||
if (colonIdx == -1) {
|
||||
this.patternBuilder.append(DEFAULT_VARIABLE_PATTERN);
|
||||
@@ -199,7 +199,7 @@ public class UriTemplate implements Serializable {
|
||||
String variableName = match.substring(0, colonIdx);
|
||||
this.variableNames.add(variableName);
|
||||
}
|
||||
end = m.end();
|
||||
end = matcher.end();
|
||||
}
|
||||
this.patternBuilder.append(quote(uriTemplate, end, uriTemplate.length()));
|
||||
int lastIdx = this.patternBuilder.length() - 1;
|
||||
|
||||
Reference in New Issue
Block a user