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

@@ -615,22 +615,17 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ConsumerCacheKey otherKey)) {
return false;
}
return (destinationEquals(otherKey) &&
ObjectUtils.nullSafeEquals(this.selector, otherKey.selector) &&
ObjectUtils.nullSafeEquals(this.noLocal, otherKey.noLocal) &&
ObjectUtils.nullSafeEquals(this.subscription, otherKey.subscription) &&
this.durable == otherKey.durable);
return (this == other || (other instanceof ConsumerCacheKey that &&
destinationEquals(that) &&
ObjectUtils.nullSafeEquals(this.selector, that.selector) &&
ObjectUtils.nullSafeEquals(this.noLocal, that.noLocal) &&
ObjectUtils.nullSafeEquals(this.subscription, that.subscription) &&
this.durable == that.durable));
}
@Override
public int hashCode() {
return (31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.selector));
return super.hashCode() * 31 + ObjectUtils.nullSafeHashCode(this.selector);
}
@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.
@@ -111,21 +111,15 @@ public class QosSettings {
@Override
public boolean equals(@Nullable Object other) {
if (this == other) {
return true;
}
if (!(other instanceof QosSettings otherSettings)) {
return false;
}
return (this.deliveryMode == otherSettings.deliveryMode &&
this.priority == otherSettings.priority &&
this.timeToLive == otherSettings.timeToLive);
return (this == other || (other instanceof QosSettings that &&
this.deliveryMode == that.deliveryMode &&
this.priority == that.priority &&
this.timeToLive == that.timeToLive));
}
@Override
public int hashCode() {
return (this.deliveryMode * 31 + this.priority);
return this.deliveryMode * 31 + this.priority;
}
@Override