Skip to content

Commit ce05a5b

Browse files
committed
Polishing
1 parent b00f98f commit ce05a5b

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -252,47 +252,47 @@ public CacheControl staleIfError(long staleIfError, TimeUnit unit) {
252252

253253

254254
/**
255-
* Return the "Cache-Control" header value.
256-
* @return {@code null} if no directive was added, or the header value otherwise
255+
* Return the "Cache-Control" header value, if any.
256+
* @return the header value, or {@code null} if no directive was added
257257
*/
258258
public String getHeaderValue() {
259-
StringBuilder ccValue = new StringBuilder();
259+
StringBuilder headerValue = new StringBuilder();
260260
if (this.maxAge != -1) {
261-
appendDirective(ccValue, "max-age=" + Long.toString(this.maxAge));
261+
appendDirective(headerValue, "max-age=" + this.maxAge);
262262
}
263263
if (this.noCache) {
264-
appendDirective(ccValue, "no-cache");
264+
appendDirective(headerValue, "no-cache");
265265
}
266266
if (this.noStore) {
267-
appendDirective(ccValue, "no-store");
267+
appendDirective(headerValue, "no-store");
268268
}
269269
if (this.mustRevalidate) {
270-
appendDirective(ccValue, "must-revalidate");
270+
appendDirective(headerValue, "must-revalidate");
271271
}
272272
if (this.noTransform) {
273-
appendDirective(ccValue, "no-transform");
273+
appendDirective(headerValue, "no-transform");
274274
}
275275
if (this.cachePublic) {
276-
appendDirective(ccValue, "public");
276+
appendDirective(headerValue, "public");
277277
}
278278
if (this.cachePrivate) {
279-
appendDirective(ccValue, "private");
279+
appendDirective(headerValue, "private");
280280
}
281281
if (this.proxyRevalidate) {
282-
appendDirective(ccValue, "proxy-revalidate");
282+
appendDirective(headerValue, "proxy-revalidate");
283283
}
284284
if (this.sMaxAge != -1) {
285-
appendDirective(ccValue, "s-maxage=" + Long.toString(this.sMaxAge));
285+
appendDirective(headerValue, "s-maxage=" + this.sMaxAge);
286286
}
287287
if (this.staleIfError != -1) {
288-
appendDirective(ccValue, "stale-if-error=" + Long.toString(this.staleIfError));
288+
appendDirective(headerValue, "stale-if-error=" + this.staleIfError);
289289
}
290290
if (this.staleWhileRevalidate != -1) {
291-
appendDirective(ccValue, "stale-while-revalidate=" + Long.toString(this.staleWhileRevalidate));
291+
appendDirective(headerValue, "stale-while-revalidate=" + this.staleWhileRevalidate);
292292
}
293293

294-
String ccHeaderValue = ccValue.toString();
295-
return (StringUtils.hasText(ccHeaderValue) ? ccHeaderValue : null);
294+
String valueString = headerValue.toString();
295+
return (StringUtils.hasText(valueString) ? valueString : null);
296296
}
297297

298298
private void appendDirective(StringBuilder builder, String value) {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,17 @@
4343
import org.springframework.util.StringUtils;
4444

4545
/**
46-
* Represents HTTP request and response headers, mapping string header names to a list of string values.
46+
* A data structure representing HTTP request or response headers, mapping String header names
47+
* to a list of String values, also offering accessors for common application-level data types.
4748
*
48-
* <p>In addition to the normal methods defined by {@link Map}, this class offers the following
49-
* convenience methods:
49+
* <p>In addition to the regular methods defined by {@link Map}, this class offers many common
50+
* convenience methods, for example:
5051
* <ul>
5152
* <li>{@link #getFirst(String)} returns the first value associated with a given header name</li>
5253
* <li>{@link #add(String, String)} adds a header value to the list of values for a header name</li>
5354
* <li>{@link #set(String, String)} sets the header value to a single string value</li>
5455
* </ul>
5556
*
56-
* <p>Inspired by {@code com.sun.net.httpserver.Headers}.
57-
*
5857
* @author Arjen Poutsma
5958
* @author Sebastien Deleuze
6059
* @author Brian Clozel
@@ -66,6 +65,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
6665

6766
private static final long serialVersionUID = -8578554704772377436L;
6867

68+
6969
/**
7070
* The HTTP {@code Accept} header field name.
7171
* @see <a href="http://tools.ietf.org/html/rfc7231#section-5.3.2">Section 5.3.2 of RFC 7231</a>
@@ -390,7 +390,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
390390

391391

392392
/**
393-
* Constructs a new, empty instance of the {@code HttpHeaders} object.
393+
* Construct a new, empty instance of the {@code HttpHeaders} object.
394394
*/
395395
public HttpHeaders() {
396396
this(new LinkedCaseInsensitiveMap<List<String>>(8, Locale.ENGLISH), false);
@@ -744,8 +744,8 @@ public long getContentLength() {
744744
* as specified by the {@code Content-Type} header.
745745
*/
746746
public void setContentType(MediaType mediaType) {
747-
Assert.isTrue(!mediaType.isWildcardType(), "'Content-Type' cannot contain wildcard type '*'");
748-
Assert.isTrue(!mediaType.isWildcardSubtype(), "'Content-Type' cannot contain wildcard subtype '*'");
747+
Assert.isTrue(!mediaType.isWildcardType(), "Content-Type cannot contain wildcard type '*'");
748+
Assert.isTrue(!mediaType.isWildcardSubtype(), "Content-Type cannot contain wildcard subtype '*'");
749749
set(CONTENT_TYPE, mediaType.toString());
750750
}
751751

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -63,6 +63,7 @@
6363
* @author Arjen Poutsma
6464
* @author Brian Clozel
6565
* @since 3.0.2
66+
* @param <T> the body type
6667
* @see #getStatusCode()
6768
*/
6869
public class ResponseEntity<T> extends HttpEntity<T> {
@@ -295,8 +296,8 @@ public static BodyBuilder unprocessableEntity() {
295296

296297
/**
297298
* Defines a builder that adds headers to the response entity.
298-
* @param <B> the builder subclass
299299
* @since 4.1
300+
* @param <B> the builder subclass
300301
*/
301302
public interface HeadersBuilder<B extends HeadersBuilder<B>> {
302303

@@ -494,7 +495,7 @@ public BodyBuilder location(URI location) {
494495
public BodyBuilder cacheControl(CacheControl cacheControl) {
495496
String ccValue = cacheControl.getHeaderValue();
496497
if (ccValue != null) {
497-
this.headers.setCacheControl(cacheControl.getHeaderValue());
498+
this.headers.setCacheControl(ccValue);
498499
}
499500
return this;
500501
}

0 commit comments

Comments
 (0)