Skip to content

Commit f5f368d

Browse files
Simplify the expression in some equals() methods
1 parent 8848f3b commit f5f368d

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

spring-amqp/src/main/java/org/springframework/amqp/core/Message.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
3636
* @author Gary Russell
3737
* @author Alex Panchenko
3838
* @author Artem Bilan
39+
* @author Ngoc Nhan
3940
*/
4041
public class Message implements Serializable {
4142

@@ -168,14 +169,9 @@ public boolean equals(Object obj) {
168169
return false;
169170
}
170171
if (this.messageProperties == null) {
171-
if (other.messageProperties != null) {
172-
return false;
173-
}
174-
}
175-
else if (!this.messageProperties.equals(other.messageProperties)) {
176-
return false;
172+
return other.messageProperties == null;
177173
}
178-
return true;
174+
return this.messageProperties.equals(other.messageProperties);
179175
}
180176

181177

spring-amqp/src/main/java/org/springframework/amqp/core/MessageProperties.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
* @author Artem Bilan
3737
* @author Csaba Soti
3838
* @author Raylax Grey
39+
* @author Ngoc Nhan
3940
*/
4041
public class MessageProperties implements Serializable {
4142

@@ -812,14 +813,9 @@ else if (!this.type.equals(other.type)) {
812813
return false;
813814
}
814815
if (this.userId == null) {
815-
if (other.userId != null) {
816-
return false;
817-
}
818-
}
819-
else if (!this.userId.equals(other.userId)) {
820-
return false;
816+
return other.userId == null;
821817
}
822-
return true;
818+
return this.userId.equals(other.userId);
823819
}
824820

825821
@Override // NOSONAR complexity

spring-amqp/src/main/java/org/springframework/amqp/core/QueueInformation.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019 the original author or authors.
2+
* Copyright 2019-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020
* Information about a queue, resulting from a passive declaration.
2121
*
2222
* @author Gary Russell
23+
* @author Ngoc Nhan
2324
* @since 2.2
2425
*
2526
*/
@@ -70,14 +71,9 @@ public boolean equals(Object obj) {
7071
}
7172
QueueInformation other = (QueueInformation) obj;
7273
if (this.name == null) {
73-
if (other.name != null) {
74-
return false;
75-
}
74+
return other.name == null;
7675
}
77-
else if (!this.name.equals(other.name)) {
78-
return false;
79-
}
80-
return true;
76+
return this.name.equals(other.name);
8177
}
8278

8379
@Override

0 commit comments

Comments
 (0)