Skip to content

Commit 77832a6

Browse files
committed
Apply "instanceof pattern matching" in HttpHeaders
1 parent ce1f6cf commit 77832a6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,19 +1773,19 @@ public Set<Entry<String, List<String>>> entrySet() {
17731773

17741774

17751775
@Override
1776-
public boolean equals(@Nullable Object other) {
1777-
if (this == other) {
1776+
public boolean equals(@Nullable Object obj) {
1777+
if (this == obj) {
17781778
return true;
17791779
}
1780-
if (!(other instanceof HttpHeaders)) {
1780+
if (!(obj instanceof HttpHeaders other)) {
17811781
return false;
17821782
}
1783-
return unwrap(this).equals(unwrap((HttpHeaders) other));
1783+
return unwrap(this).equals(unwrap(other));
17841784
}
17851785

17861786
private static MultiValueMap<String, String> unwrap(HttpHeaders headers) {
1787-
while (headers.headers instanceof HttpHeaders) {
1788-
headers = (HttpHeaders) headers.headers;
1787+
while (headers.headers instanceof HttpHeaders httpHeaders) {
1788+
headers = httpHeaders;
17891789
}
17901790
return headers.headers;
17911791
}
@@ -1810,8 +1810,8 @@ public String toString() {
18101810
* @since 5.3
18111811
*/
18121812
public static HttpHeaders readOnlyHttpHeaders(MultiValueMap<String, String> headers) {
1813-
return (headers instanceof HttpHeaders ?
1814-
readOnlyHttpHeaders((HttpHeaders) headers) : new ReadOnlyHttpHeaders(headers));
1813+
return (headers instanceof HttpHeaders httpHeaders ? readOnlyHttpHeaders(httpHeaders) :
1814+
new ReadOnlyHttpHeaders(headers));
18151815
}
18161816

18171817
/**

0 commit comments

Comments
 (0)