spring-projects/spring-framework — pull request #536 by matsev (2014-05-01 21:35:59+00:00)
Title: Created a builder to create HttpHeaders

Implemented a simple builder that creates a HttpHeaders instance by
wrapping calls to an internal HttpHeaders object. The builder pattern
allows both creation of simple objects as well as chaining calls to more
complex constructs.

The major disadvantage with this implementation compared to the
proposed solution in the issue is that it is more verbose when only a
single header is desired. On the other hand, the fluent API will make
the creation of a HttpHeaders object concise if more parameters are
added. Additionally, the builder pattern enables methods like
setContentType(MediaType mediaType) to be implemented in a type-safe
way.

Example usages:

HttpHeaders etagHeader = new HttpHeadersBuilder.setETag(etagValue).build();

HttpHeaders httpHeader = new HttpHeadersBuilder
.setETag(etagValue)
.setContentType(MediaType.APPLICATION_JSON)
.setContentLength(42L)
// more setters
.build();

Issue: SPR-11597