Skip to content

Commit

Permalink
Simplify the expression in some equals() methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ngocnhan-tran1996 authored Oct 10, 2024
1 parent 8848f3b commit f5f368d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
Expand Down Expand Up @@ -36,6 +36,7 @@
* @author Gary Russell
* @author Alex Panchenko
* @author Artem Bilan
* @author Ngoc Nhan
*/
public class Message implements Serializable {

Expand Down Expand Up @@ -168,14 +169,9 @@ public boolean equals(Object obj) {
return false;
}
if (this.messageProperties == null) {
if (other.messageProperties != null) {
return false;
}
}
else if (!this.messageProperties.equals(other.messageProperties)) {
return false;
return other.messageProperties == null;
}
return true;
return this.messageProperties.equals(other.messageProperties);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* @author Artem Bilan
* @author Csaba Soti
* @author Raylax Grey
* @author Ngoc Nhan
*/
public class MessageProperties implements Serializable {

Expand Down Expand Up @@ -812,14 +813,9 @@ else if (!this.type.equals(other.type)) {
return false;
}
if (this.userId == null) {
if (other.userId != null) {
return false;
}
}
else if (!this.userId.equals(other.userId)) {
return false;
return other.userId == null;
}
return true;
return this.userId.equals(other.userId);
}

@Override // NOSONAR complexity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 the original author or authors.
* Copyright 2019-2024 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.
Expand All @@ -20,6 +20,7 @@
* Information about a queue, resulting from a passive declaration.
*
* @author Gary Russell
* @author Ngoc Nhan
* @since 2.2
*
*/
Expand Down Expand Up @@ -70,14 +71,9 @@ public boolean equals(Object obj) {
}
QueueInformation other = (QueueInformation) obj;
if (this.name == null) {
if (other.name != null) {
return false;
}
return other.name == null;
}
else if (!this.name.equals(other.name)) {
return false;
}
return true;
return this.name.equals(other.name);
}

@Override
Expand Down

0 comments on commit f5f368d

Please sign in to comment.