Consistent equals/hashCode style (and related polishing)

This commit is contained in:
Juergen Hoeller
2023-07-19 00:35:19 +02:00
parent bbcc788f60
commit 2f33e77ab4
98 changed files with 413 additions and 835 deletions

View File

@@ -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.
@@ -76,13 +76,8 @@ public abstract class AbstractWebSocketMessage<T> implements WebSocketMessage<T>
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AbstractWebSocketMessage<?> otherMessage)) {
return false;
}
return ObjectUtils.nullSafeEquals(this.payload, otherMessage.payload);
return (this == other || (other instanceof AbstractWebSocketMessage<?> that &&
ObjectUtils.nullSafeEquals(this.payload, that.payload)));
}
@Override

View File

@@ -207,13 +207,8 @@ public final class CloseStatus implements Serializable {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof CloseStatus otherStatus)) {
return false;
}
return (this.code == otherStatus.code && ObjectUtils.nullSafeEquals(this.reason, otherStatus.reason));
return (this == other || (other instanceof CloseStatus that &&
this.code == that.code && ObjectUtils.nullSafeEquals(this.reason, that.reason)));
}
@Override

View File

@@ -309,13 +309,8 @@ public class WebSocketHttpHeaders extends HttpHeaders {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof WebSocketHttpHeaders otherHeaders)) {
return false;
}
return this.headers.equals(otherHeaders.headers);
return (this == other || (other instanceof WebSocketHttpHeaders that &&
this.headers.equals(that.headers)));
}
@Override

View File

@@ -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.
@@ -238,8 +238,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
@Override
public boolean equals(@Nullable Object other) {
return (this == other ||
(other instanceof SimpUser otherSimpUser && getName().equals(otherSimpUser.getName())));
return (this == other || (other instanceof SimpUser that && getName().equals(that.getName())));
}
@Override
@@ -294,8 +293,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
@Override
public boolean equals(@Nullable Object other) {
return (this == other ||
(other instanceof SimpSubscription otherSubscription && getId().equals(otherSubscription.getId())));
return (this == other || (other instanceof SimpSubscription that && getId().equals(that.getId())));
}
@Override
@@ -344,14 +342,9 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof SimpSubscription otherSubscription)) {
return false;
}
return (getId().equals(otherSubscription.getId()) &&
getSession().getId().equals(otherSubscription.getSession().getId()));
return (this == other || (other instanceof SimpSubscription that &&
getId().equals(that.getId()) &&
getSession().getId().equals(that.getSession().getId())));
}
@Override

View File

@@ -122,13 +122,8 @@ public class SockJsFrame {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof SockJsFrame otherFrame)) {
return false;
}
return (this.type.equals(otherFrame.type) && this.content.equals(otherFrame.content));
return (this == other || (other instanceof SockJsFrame that &&
this.type.equals(that.type) && this.content.equals(that.content)));
}
@Override