Skip to content

Commit 3264437

Browse files
committed
Polishing
1 parent 3d4e73b commit 3264437

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 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.
@@ -138,20 +138,20 @@ public boolean equals(Object other) {
138138

139139
@Override
140140
public int hashCode() {
141-
return ObjectUtils.nullSafeHashCode(this.headers) * 29 + ObjectUtils.nullSafeHashCode(this.body);
141+
return (ObjectUtils.nullSafeHashCode(this.headers) * 29 + ObjectUtils.nullSafeHashCode(this.body));
142142
}
143143

144144
@Override
145145
public String toString() {
146146
StringBuilder builder = new StringBuilder("<");
147-
if (body != null) {
148-
builder.append(body);
149-
if (headers != null) {
147+
if (this.body != null) {
148+
builder.append(this.body);
149+
if (this.headers != null) {
150150
builder.append(',');
151151
}
152152
}
153-
if (headers != null) {
154-
builder.append(headers);
153+
if (this.headers != null) {
154+
builder.append(this.headers);
155155
}
156156
builder.append('>');
157157
return builder.toString();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ public boolean equals(Object other) {
106106
if (this == other) {
107107
return true;
108108
}
109-
if (!(other instanceof ResponseEntity)) {
109+
if (!(other instanceof ResponseEntity) || !super.equals(other)) {
110110
return false;
111111
}
112112
ResponseEntity<?> otherEntity = (ResponseEntity<?>) other;
113-
return (ObjectUtils.nullSafeEquals(this.statusCode, otherEntity.statusCode) && super.equals(other));
113+
return ObjectUtils.nullSafeEquals(this.statusCode, otherEntity.statusCode);
114114
}
115115

116116
@Override
117117
public int hashCode() {
118-
return super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.statusCode);
118+
return (super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.statusCode));
119119
}
120120

121121
@Override

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 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.
@@ -105,6 +105,7 @@ public interface RestOperations {
105105
*/
106106
<T> ResponseEntity<T> getForEntity(URI url, Class<T> responseType) throws RestClientException;
107107

108+
108109
// HEAD
109110

110111
/**
@@ -132,6 +133,7 @@ public interface RestOperations {
132133
*/
133134
HttpHeaders headForHeaders(URI url) throws RestClientException;
134135

136+
135137
// POST
136138

137139
/**
@@ -264,6 +266,7 @@ <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> respons
264266
*/
265267
<T> ResponseEntity<T> postForEntity(URI url, Object request, Class<T> responseType) throws RestClientException;
266268

269+
267270
// PUT
268271

269272
/**
@@ -300,6 +303,7 @@ <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> respons
300303
*/
301304
void put(URI url, Object request) throws RestClientException;
302305

306+
303307
// DELETE
304308

305309
/**
@@ -325,6 +329,7 @@ <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> respons
325329
*/
326330
void delete(URI url) throws RestClientException;
327331

332+
328333
// OPTIONS
329334

330335
/**
@@ -352,6 +357,7 @@ <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> respons
352357
*/
353358
Set<HttpMethod> optionsForAllow(URI url) throws RestClientException;
354359

360+
355361
// exchange
356362

357363
/**
@@ -401,20 +407,18 @@ <T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> request
401407
* Execute the HTTP method to the given URI template, writing the given
402408
* request entity to the request, and returns the response as {@link ResponseEntity}.
403409
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
404-
*
405410
* <pre class="code">
406411
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
407412
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
408413
* </pre>
409-
*
410414
* @param url the URL
411415
* @param method the HTTP method (GET, POST, etc)
412416
* @param requestEntity the entity (headers and/or body) to write to the
413417
* request, may be {@code null}
414418
* @param responseType the type of the return value
415419
* @param uriVariables the variables to expand in the template
416420
* @return the response as entity
417-
* @since 3.2.0
421+
* @since 3.2
418422
*/
419423
<T> ResponseEntity<T> exchange(String url,HttpMethod method, HttpEntity<?> requestEntity,
420424
ParameterizedTypeReference<T> responseType, Object... uriVariables) throws RestClientException;
@@ -423,19 +427,17 @@ <T> ResponseEntity<T> exchange(String url,HttpMethod method, HttpEntity<?> reque
423427
* Execute the HTTP method to the given URI template, writing the given
424428
* request entity to the request, and returns the response as {@link ResponseEntity}.
425429
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
426-
*
427430
* <pre class="code">
428431
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
429432
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
430433
* </pre>
431-
*
432434
* @param url the URL
433435
* @param method the HTTP method (GET, POST, etc)
434436
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null}
435437
* @param responseType the type of the return value
436438
* @param uriVariables the variables to expand in the template
437439
* @return the response as entity
438-
* @since 3.2.0
440+
* @since 3.2
439441
*/
440442
<T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
441443
ParameterizedTypeReference<T> responseType, Map<String, ?> uriVariables) throws RestClientException;
@@ -444,22 +446,21 @@ <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requ
444446
* Execute the HTTP method to the given URI template, writing the given
445447
* request entity to the request, and returns the response as {@link ResponseEntity}.
446448
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
447-
*
448449
* <pre class="code">
449450
* ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
450451
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean);
451452
* </pre>
452-
*
453453
* @param url the URL
454454
* @param method the HTTP method (GET, POST, etc)
455455
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null}
456456
* @param responseType the type of the return value
457457
* @return the response as entity
458-
* @since 3.2.0
458+
* @since 3.2
459459
*/
460460
<T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity,
461461
ParameterizedTypeReference<T> responseType) throws RestClientException;
462462

463+
463464
// general execution
464465

465466
/**

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ public <T> ResponseEntity<T> getForEntity(URI url, Class<T> responseType) throws
280280
return execute(url, HttpMethod.GET, requestCallback, responseExtractor);
281281
}
282282

283+
283284
// HEAD
284285

285286
public HttpHeaders headForHeaders(String url, Object... urlVariables) throws RestClientException {
@@ -294,6 +295,7 @@ public HttpHeaders headForHeaders(URI url) throws RestClientException {
294295
return execute(url, HttpMethod.HEAD, null, this.headersExtractor);
295296
}
296297

298+
297299
// POST
298300

299301
public URI postForLocation(String url, Object request, Object... urlVariables) throws RestClientException {
@@ -366,6 +368,7 @@ public <T> ResponseEntity<T> postForEntity(URI url, Object request, Class<T> res
366368
return execute(url, HttpMethod.POST, requestCallback, responseExtractor);
367369
}
368370

371+
369372
// PUT
370373

371374
public void put(String url, Object request, Object... urlVariables) throws RestClientException {
@@ -383,6 +386,7 @@ public void put(URI url, Object request) throws RestClientException {
383386
execute(url, HttpMethod.PUT, requestCallback, null);
384387
}
385388

389+
386390
// DELETE
387391

388392
public void delete(String url, Object... urlVariables) throws RestClientException {
@@ -397,6 +401,7 @@ public void delete(URI url) throws RestClientException {
397401
execute(url, HttpMethod.DELETE, null, null);
398402
}
399403

404+
400405
// OPTIONS
401406

402407
public Set<HttpMethod> optionsForAllow(String url, Object... urlVariables) throws RestClientException {
@@ -414,6 +419,7 @@ public Set<HttpMethod> optionsForAllow(URI url) throws RestClientException {
414419
return headers.getAllow();
415420
}
416421

422+
417423
// exchange
418424

419425
public <T> ResponseEntity<T> exchange(String url, HttpMethod method,

0 commit comments

Comments
 (0)