Skip to content

Commit

Permalink
Apply "instanceof pattern matching" in HttpHeaders
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Jan 9, 2023
1 parent ce1f6cf commit 77832a6
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1773,19 +1773,19 @@ public Set<Entry<String, List<String>>> entrySet() {


@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (!(other instanceof HttpHeaders)) {
if (!(obj instanceof HttpHeaders other)) {
return false;
}
return unwrap(this).equals(unwrap((HttpHeaders) other));
return unwrap(this).equals(unwrap(other));
}

private static MultiValueMap<String, String> unwrap(HttpHeaders headers) {
while (headers.headers instanceof HttpHeaders) {
headers = (HttpHeaders) headers.headers;
while (headers.headers instanceof HttpHeaders httpHeaders) {
headers = httpHeaders;
}
return headers.headers;
}
Expand All @@ -1810,8 +1810,8 @@ public String toString() {
* @since 5.3
*/
public static HttpHeaders readOnlyHttpHeaders(MultiValueMap<String, String> headers) {
return (headers instanceof HttpHeaders ?
readOnlyHttpHeaders((HttpHeaders) headers) : new ReadOnlyHttpHeaders(headers));
return (headers instanceof HttpHeaders httpHeaders ? readOnlyHttpHeaders(httpHeaders) :
new ReadOnlyHttpHeaders(headers));
}

/**
Expand Down

0 comments on commit 77832a6

Please sign in to comment.