Consistent equals/hashCode style (and related polishing)
This commit is contained in:
@@ -227,20 +227,15 @@ public final class ContentDisposition {
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof ContentDisposition otherCd)) {
|
||||
return false;
|
||||
}
|
||||
return (ObjectUtils.nullSafeEquals(this.type, otherCd.type) &&
|
||||
ObjectUtils.nullSafeEquals(this.name, otherCd.name) &&
|
||||
ObjectUtils.nullSafeEquals(this.filename, otherCd.filename) &&
|
||||
ObjectUtils.nullSafeEquals(this.charset, otherCd.charset) &&
|
||||
ObjectUtils.nullSafeEquals(this.size, otherCd.size) &&
|
||||
ObjectUtils.nullSafeEquals(this.creationDate, otherCd.creationDate)&&
|
||||
ObjectUtils.nullSafeEquals(this.modificationDate, otherCd.modificationDate)&&
|
||||
ObjectUtils.nullSafeEquals(this.readDate, otherCd.readDate));
|
||||
return (this == other || (other instanceof ContentDisposition that &&
|
||||
ObjectUtils.nullSafeEquals(this.type, that.type) &&
|
||||
ObjectUtils.nullSafeEquals(this.name, that.name) &&
|
||||
ObjectUtils.nullSafeEquals(this.filename, that.filename) &&
|
||||
ObjectUtils.nullSafeEquals(this.charset, that.charset) &&
|
||||
ObjectUtils.nullSafeEquals(this.size, that.size) &&
|
||||
ObjectUtils.nullSafeEquals(this.creationDate, that.creationDate)&&
|
||||
ObjectUtils.nullSafeEquals(this.modificationDate, that.modificationDate)&&
|
||||
ObjectUtils.nullSafeEquals(this.readDate, that.readDate)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,19 +57,14 @@ public class HttpCookie {
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode();
|
||||
public boolean equals(@Nullable Object other) {
|
||||
return (this == other || (other instanceof HttpCookie that &&
|
||||
this.name.equalsIgnoreCase(that.getName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof HttpCookie otherCookie)) {
|
||||
return false;
|
||||
}
|
||||
return (this.name.equalsIgnoreCase(otherCookie.getName()));
|
||||
public int hashCode() {
|
||||
return this.name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -269,14 +269,9 @@ public abstract class HttpRange {
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof ByteRange otherRange)) {
|
||||
return false;
|
||||
}
|
||||
return (this.firstPos == otherRange.firstPos &&
|
||||
ObjectUtils.nullSafeEquals(this.lastPos, otherRange.lastPos));
|
||||
return (this == other || (other instanceof ByteRange that &&
|
||||
this.firstPos == that.firstPos &&
|
||||
ObjectUtils.nullSafeEquals(this.lastPos, that.lastPos)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -331,13 +326,8 @@ public abstract class HttpRange {
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof SuffixByteRange otherRange)) {
|
||||
return false;
|
||||
}
|
||||
return (this.suffixLength == otherRange.suffixLength);
|
||||
return (this == other || (other instanceof SuffixByteRange that &&
|
||||
this.suffixLength == that.suffixLength));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -233,18 +233,13 @@ public class ProblemDetail {
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof ProblemDetail otherDetail)) {
|
||||
return false;
|
||||
}
|
||||
return (getType().equals(otherDetail.getType()) &&
|
||||
ObjectUtils.nullSafeEquals(getTitle(), otherDetail.getTitle()) &&
|
||||
this.status == otherDetail.status &&
|
||||
ObjectUtils.nullSafeEquals(this.detail, otherDetail.detail) &&
|
||||
ObjectUtils.nullSafeEquals(this.instance, otherDetail.instance) &&
|
||||
ObjectUtils.nullSafeEquals(this.properties, otherDetail.properties));
|
||||
return (this == other || (other instanceof ProblemDetail that &&
|
||||
getType().equals(that.getType()) &&
|
||||
ObjectUtils.nullSafeEquals(getTitle(), that.getTitle()) &&
|
||||
this.status == that.status &&
|
||||
ObjectUtils.nullSafeEquals(this.detail, that.detail) &&
|
||||
ObjectUtils.nullSafeEquals(this.instance, that.instance) &&
|
||||
ObjectUtils.nullSafeEquals(this.properties, that.properties)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -144,15 +144,10 @@ public final class ResponseCookie extends HttpCookie {
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof ResponseCookie otherCookie)) {
|
||||
return false;
|
||||
}
|
||||
return (getName().equalsIgnoreCase(otherCookie.getName()) &&
|
||||
ObjectUtils.nullSafeEquals(this.path, otherCookie.getPath()) &&
|
||||
ObjectUtils.nullSafeEquals(this.domain, otherCookie.getDomain()));
|
||||
return (this == other ||(other instanceof ResponseCookie that &&
|
||||
getName().equalsIgnoreCase(that.getName()) &&
|
||||
ObjectUtils.nullSafeEquals(this.path, that.getPath()) &&
|
||||
ObjectUtils.nullSafeEquals(this.domain, that.getDomain())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,7 +41,7 @@ public class ClientRequestObservationContext extends RequestReplySenderContext<C
|
||||
*/
|
||||
public ClientRequestObservationContext(ClientHttpRequest request) {
|
||||
super(ClientRequestObservationContext::setRequestHeader);
|
||||
this.setCarrier(request);
|
||||
setCarrier(request);
|
||||
}
|
||||
|
||||
private static void setRequestHeader(@Nullable ClientHttpRequest request, String name, String value) {
|
||||
|
||||
@@ -160,7 +160,7 @@ class ReactorNetty2ClientHttpResponse implements ClientHttpResponse {
|
||||
}
|
||||
|
||||
private boolean mayHaveBody(HttpMethod method) {
|
||||
int code = this.getStatusCode().value();
|
||||
int code = getStatusCode().value();
|
||||
return !((code >= 100 && code < 200) || code == 204 || code == 205 ||
|
||||
method.equals(HttpMethod.HEAD) || getHeaders().getContentLength() == 0);
|
||||
}
|
||||
|
||||
@@ -244,13 +244,8 @@ public class ServletContextResource extends AbstractFileResolvingResource implem
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof ServletContextResource otherRes)) {
|
||||
return false;
|
||||
}
|
||||
return (this.servletContext.equals(otherRes.servletContext) && this.path.equals(otherRes.path));
|
||||
return (this == other || (other instanceof ServletContextResource that &&
|
||||
this.path.equals(that.path) && this.servletContext.equals(that.servletContext)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -161,10 +161,10 @@ public class DelegatingFilterProxy extends GenericFilterBean {
|
||||
*/
|
||||
public DelegatingFilterProxy(String targetBeanName, @Nullable WebApplicationContext wac) {
|
||||
Assert.hasText(targetBeanName, "Target Filter bean name must not be null or empty");
|
||||
this.setTargetBeanName(targetBeanName);
|
||||
setTargetBeanName(targetBeanName);
|
||||
this.webApplicationContext = wac;
|
||||
if (wac != null) {
|
||||
this.setEnvironment(wac.getEnvironment());
|
||||
setEnvironment(wac.getEnvironment());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -257,13 +257,8 @@ public class ControllerAdviceBean implements Ordered {
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof ControllerAdviceBean otherAdvice)) {
|
||||
return false;
|
||||
}
|
||||
return (this.beanOrName.equals(otherAdvice.beanOrName) && this.beanFactory == otherAdvice.beanFactory);
|
||||
return (this == other || (other instanceof ControllerAdviceBean that &&
|
||||
this.beanOrName.equals(that.beanOrName) && this.beanFactory == that.beanFactory));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -74,7 +74,7 @@ public class HeaderWebSessionIdResolver implements WebSessionIdResolver {
|
||||
|
||||
@Override
|
||||
public void expireSession(ServerWebExchange exchange) {
|
||||
this.setSessionId(exchange, "");
|
||||
setSessionId(exchange, "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -554,19 +554,14 @@ final class HierarchicalUriComponents extends UriComponents {
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof HierarchicalUriComponents otherComp)) {
|
||||
return false;
|
||||
}
|
||||
return (ObjectUtils.nullSafeEquals(getScheme(), otherComp.getScheme()) &&
|
||||
ObjectUtils.nullSafeEquals(getUserInfo(), otherComp.getUserInfo()) &&
|
||||
ObjectUtils.nullSafeEquals(getHost(), otherComp.getHost()) &&
|
||||
getPort() == otherComp.getPort() &&
|
||||
this.path.equals(otherComp.path) &&
|
||||
this.queryParams.equals(otherComp.queryParams) &&
|
||||
ObjectUtils.nullSafeEquals(getFragment(), otherComp.getFragment()));
|
||||
return (this == other || (other instanceof HierarchicalUriComponents that &&
|
||||
ObjectUtils.nullSafeEquals(getScheme(), that.getScheme()) &&
|
||||
ObjectUtils.nullSafeEquals(getUserInfo(), that.getUserInfo()) &&
|
||||
ObjectUtils.nullSafeEquals(getHost(), that.getHost()) &&
|
||||
getPort() == that.getPort() &&
|
||||
this.path.equals(that.path) &&
|
||||
this.queryParams.equals(that.queryParams) &&
|
||||
ObjectUtils.nullSafeEquals(getFragment(), that.getFragment())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -158,15 +158,10 @@ final class OpaqueUriComponents extends UriComponents {
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof OpaqueUriComponents otherComp)) {
|
||||
return false;
|
||||
}
|
||||
return (ObjectUtils.nullSafeEquals(getScheme(), otherComp.getScheme()) &&
|
||||
ObjectUtils.nullSafeEquals(this.ssp, otherComp.ssp) &&
|
||||
ObjectUtils.nullSafeEquals(getFragment(), otherComp.getFragment()));
|
||||
return (this == other || (other instanceof OpaqueUriComponents that &&
|
||||
ObjectUtils.nullSafeEquals(getScheme(), that.getScheme()) &&
|
||||
ObjectUtils.nullSafeEquals(this.ssp, that.ssp) &&
|
||||
ObjectUtils.nullSafeEquals(getFragment(), that.getFragment())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -432,12 +432,10 @@ public class PathPattern implements Comparable<PathPattern> {
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object other) {
|
||||
if (!(other instanceof PathPattern otherPattern)) {
|
||||
return false;
|
||||
}
|
||||
return (this.patternString.equals(otherPattern.getPatternString()) &&
|
||||
getSeparator() == otherPattern.getSeparator() &&
|
||||
this.caseSensitive == otherPattern.caseSensitive);
|
||||
return (this == other || (other instanceof PathPattern that &&
|
||||
this.patternString.equals(that.getPatternString()) &&
|
||||
getSeparator() == that.getSeparator() &&
|
||||
this.caseSensitive == that.caseSensitive));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user