Skip to content

Commit a5a56d5

Browse files
committed
Polishing
1 parent 81ba3b3 commit a5a56d5

File tree

6 files changed

+47
-52
lines changed

6 files changed

+47
-52
lines changed

spring-web/src/main/java/org/springframework/http/ResponseEntity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ private static class DefaultBuilder implements BodyBuilder {
348348

349349
private final HttpHeaders headers = new HttpHeaders();
350350

351-
352351
public DefaultBuilder(HttpStatus status) {
353352
this.status = status;
354353
}
@@ -397,7 +396,6 @@ public BodyBuilder location(URI location) {
397396
return this;
398397
}
399398

400-
401399
@Override
402400
public ResponseEntity<Void> build() {
403401
return new ResponseEntity<Void>(null, this.headers, this.status);

spring-web/src/main/java/org/springframework/web/client/RestTemplate.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,9 @@ public <T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?>
488488
}
489489

490490
@Override
491-
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity,
492-
Class<T> responseType) throws RestClientException {
491+
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, Class<T> responseType)
492+
throws RestClientException {
493+
493494
Assert.notNull(requestEntity, "'requestEntity' must not be null");
494495

495496
RequestCallback requestCallback = httpEntityCallback(requestEntity, responseType);
@@ -498,8 +499,9 @@ public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity,
498499
}
499500

500501
@Override
501-
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity,
502-
ParameterizedTypeReference<T> responseType) throws RestClientException {
502+
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)
503+
throws RestClientException {
504+
503505
Assert.notNull(requestEntity, "'requestEntity' must not be null");
504506

505507
Type type = responseType.getType();

spring-web/src/main/java/org/springframework/web/util/OpaqueUriComponents.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -95,10 +95,10 @@ public UriComponents encode(String encoding) throws UnsupportedEncodingException
9595

9696
@Override
9797
protected UriComponents expandInternal(UriTemplateVariables uriVariables) {
98-
String expandedScheme = expandUriComponent(this.getScheme(), uriVariables);
99-
String expandedSSp = expandUriComponent(this.ssp, uriVariables);
100-
String expandedFragment = expandUriComponent(this.getFragment(), uriVariables);
101-
return new OpaqueUriComponents(expandedScheme, expandedSSp, expandedFragment);
98+
String expandedScheme = expandUriComponent(getScheme(), uriVariables);
99+
String expandedSsp = expandUriComponent(getSchemeSpecificPart(), uriVariables);
100+
String expandedFragment = expandUriComponent(getFragment(), uriVariables);
101+
return new OpaqueUriComponents(expandedScheme, expandedSsp, expandedFragment);
102102
}
103103

104104
@Override

spring-web/src/main/java/org/springframework/web/util/UriComponents.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ public interface UriTemplateVariables {
252252
* Get the value for the given URI variable name.
253253
* If the value is {@code null}, an empty String is expanded.
254254
* If the value is {@link #SKIP_VALUE}, the URI variable is not expanded.
255-
*
256255
* @param name the variable name
257256
* @return the variable value, possibly {@code null} or {@link #SKIP_VALUE}
258257
*/
@@ -295,8 +294,7 @@ public VarArgsTemplateVariables(Object... uriVariableValues) {
295294
@Override
296295
public Object getValue(String name) {
297296
if (!this.valueIterator.hasNext()) {
298-
throw new IllegalArgumentException(
299-
"Not enough variable values available to expand '" + name + "'");
297+
throw new IllegalArgumentException("Not enough variable values available to expand '" + name + "'");
300298
}
301299
return this.valueIterator.next();
302300
}

spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,20 @@ public static UriComponentsBuilder fromUri(URI uri) {
163163
*/
164164
public static UriComponentsBuilder fromUriString(String uri) {
165165
Assert.hasLength(uri, "'uri' must not be empty");
166-
Matcher m = URI_PATTERN.matcher(uri);
167-
if (m.matches()) {
166+
Matcher matcher = URI_PATTERN.matcher(uri);
167+
if (matcher.matches()) {
168168
UriComponentsBuilder builder = new UriComponentsBuilder();
169-
String scheme = m.group(2);
170-
String userInfo = m.group(5);
171-
String host = m.group(6);
172-
String port = m.group(8);
173-
String path = m.group(9);
174-
String query = m.group(11);
175-
String fragment = m.group(13);
169+
String scheme = matcher.group(2);
170+
String userInfo = matcher.group(5);
171+
String host = matcher.group(6);
172+
String port = matcher.group(8);
173+
String path = matcher.group(9);
174+
String query = matcher.group(11);
175+
String fragment = matcher.group(13);
176176
boolean opaque = false;
177177
if (StringUtils.hasLength(scheme)) {
178-
String s = uri.substring(scheme.length());
179-
if (!s.startsWith(":/")) {
178+
String rest = uri.substring(scheme.length());
179+
if (!rest.startsWith(":/")) {
180180
opaque = true;
181181
}
182182
}
@@ -223,25 +223,23 @@ public static UriComponentsBuilder fromUriString(String uri) {
223223
*/
224224
public static UriComponentsBuilder fromHttpUrl(String httpUrl) {
225225
Assert.notNull(httpUrl, "'httpUrl' must not be null");
226-
Matcher m = HTTP_URL_PATTERN.matcher(httpUrl);
227-
if (m.matches()) {
226+
Matcher matcher = HTTP_URL_PATTERN.matcher(httpUrl);
227+
if (matcher.matches()) {
228228
UriComponentsBuilder builder = new UriComponentsBuilder();
229-
230-
String scheme = m.group(1);
231-
builder.scheme((scheme != null) ? scheme.toLowerCase() : scheme);
232-
builder.userInfo(m.group(4));
233-
String host = m.group(5);
229+
String scheme = matcher.group(1);
230+
builder.scheme(scheme != null ? scheme.toLowerCase() : null);
231+
builder.userInfo(matcher.group(4));
232+
String host = matcher.group(5);
234233
if (StringUtils.hasLength(scheme) && !StringUtils.hasLength(host)) {
235234
throw new IllegalArgumentException("[" + httpUrl + "] is not a valid HTTP URL");
236235
}
237236
builder.host(host);
238-
String port = m.group(7);
237+
String port = matcher.group(7);
239238
if (StringUtils.hasLength(port)) {
240239
builder.port(port);
241240
}
242-
builder.path(m.group(8));
243-
builder.query(m.group(10));
244-
241+
builder.path(matcher.group(8));
242+
builder.query(matcher.group(10));
245243
return builder;
246244
}
247245
else {
@@ -264,7 +262,7 @@ public UriComponents build() {
264262
* Build a {@code UriComponents} instance from the various components
265263
* contained in this builder.
266264
* @param encoded whether all the components set in this builder are
267-
* encoded ({@code true}) or not ({@code false}).
265+
* encoded ({@code true}) or not ({@code false})
268266
* @return the URI components
269267
*/
270268
public UriComponents build(boolean encoded) {
@@ -533,13 +531,12 @@ public UriComponentsBuilder pathSegment(String... pathSegments) throws IllegalAr
533531
*/
534532
public UriComponentsBuilder query(String query) {
535533
if (query != null) {
536-
Matcher m = QUERY_PARAM_PATTERN.matcher(query);
537-
while (m.find()) {
538-
String name = m.group(1);
539-
String eq = m.group(2);
540-
String value = m.group(3);
541-
queryParam(name, (value != null ? value :
542-
(StringUtils.hasLength(eq) ? "" : null)));
534+
Matcher matcher = QUERY_PARAM_PATTERN.matcher(query);
535+
while (matcher.find()) {
536+
String name = matcher.group(1);
537+
String eq = matcher.group(2);
538+
String value = matcher.group(3);
539+
queryParam(name, (value != null ? value : (StringUtils.hasLength(eq) ? "" : null)));
543540
}
544541
}
545542
else {
@@ -574,7 +571,7 @@ public UriComponentsBuilder queryParam(String name, Object... values) {
574571
Assert.notNull(name, "'name' must not be null");
575572
if (!ObjectUtils.isEmpty(values)) {
576573
for (Object value : values) {
577-
String valueAsString = value != null ? value.toString() : null;
574+
String valueAsString = (value != null ? value.toString() : null);
578575
this.queryParams.add(name, valueAsString);
579576
}
580577
}

spring-web/src/main/java/org/springframework/web/util/UriTemplate.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public List<String> getVariableNames() {
9696
* or if it does not contain values for all the variable names
9797
*/
9898
public URI expand(Map<String, ?> uriVariables) {
99-
UriComponents expandedComponents = uriComponents.expand(uriVariables);
99+
UriComponents expandedComponents = this.uriComponents.expand(uriVariables);
100100
UriComponents encodedComponents = expandedComponents.encode();
101101
return encodedComponents.toUri();
102102
}
@@ -116,7 +116,7 @@ public URI expand(Map<String, ?> uriVariables) {
116116
* or if it does not contain sufficient variables
117117
*/
118118
public URI expand(Object... uriVariableValues) {
119-
UriComponents expandedComponents = uriComponents.expand(uriVariableValues);
119+
UriComponents expandedComponents = this.uriComponents.expand(uriVariableValues);
120120
UriComponents encodedComponents = expandedComponents.encode();
121121
return encodedComponents.toUri();
122122
}
@@ -177,11 +177,11 @@ private static class Parser {
177177

178178
private Parser(String uriTemplate) {
179179
Assert.hasText(uriTemplate, "'uriTemplate' must not be null");
180-
Matcher m = NAMES_PATTERN.matcher(uriTemplate);
180+
Matcher matcher = NAMES_PATTERN.matcher(uriTemplate);
181181
int end = 0;
182-
while (m.find()) {
183-
this.patternBuilder.append(quote(uriTemplate, end, m.start()));
184-
String match = m.group(1);
182+
while (matcher.find()) {
183+
this.patternBuilder.append(quote(uriTemplate, end, matcher.start()));
184+
String match = matcher.group(1);
185185
int colonIdx = match.indexOf(':');
186186
if (colonIdx == -1) {
187187
this.patternBuilder.append(DEFAULT_VARIABLE_PATTERN);
@@ -199,7 +199,7 @@ private Parser(String uriTemplate) {
199199
String variableName = match.substring(0, colonIdx);
200200
this.variableNames.add(variableName);
201201
}
202-
end = m.end();
202+
end = matcher.end();
203203
}
204204
this.patternBuilder.append(quote(uriTemplate, end, uriTemplate.length()));
205205
int lastIdx = this.patternBuilder.length() - 1;

0 commit comments

Comments
 (0)