ARTEMIS-2320 'compare()' method can be used to compare numbers

This commit is contained in:
Jiri Danek 2019-04-26 22:37:45 +02:00 committed by Michael Andre Pearce
parent d076d1ca59
commit 34e5d607ef
3 changed files with 3 additions and 15 deletions

View File

@ -239,13 +239,7 @@ public final class XmlDataImporter extends ActionAbstract {
messages = new TreeSet<XMLMessageImporter.MessageInfo>(new Comparator<XMLMessageImporter.MessageInfo>() { messages = new TreeSet<XMLMessageImporter.MessageInfo>(new Comparator<XMLMessageImporter.MessageInfo>() {
@Override @Override
public int compare(XMLMessageImporter.MessageInfo o1, XMLMessageImporter.MessageInfo o2) { public int compare(XMLMessageImporter.MessageInfo o1, XMLMessageImporter.MessageInfo o2) {
if (o1.id == o2.id) { return Long.compare(o1.id, o2.id);
return 0;
} else if (o1.id > o2.id) {
return 1;
} else {
return -1;
}
} }
}); });
} }

View File

@ -110,13 +110,7 @@ public class PagePositionImpl implements PagePosition {
return 1; return 1;
} else if (pageNr < o.getPageNr()) { } else if (pageNr < o.getPageNr()) {
return -1; return -1;
} else if (recordID > o.getRecordID()) { } else return Long.compare(recordID, o.getRecordID());
return 1;
} else if (recordID < o.getRecordID()) {
return -1;
} else {
return 0;
}
} }
@Override @Override

View File

@ -1106,7 +1106,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase {
public int compareTo(final OrderedConsumerHolder o) { public int compareTo(final OrderedConsumerHolder o) {
int thisOrder = order; int thisOrder = order;
int otherOrder = o.order; int otherOrder = o.order;
return thisOrder < otherOrder ? -1 : thisOrder == otherOrder ? 0 : 1; return Integer.compare(thisOrder, otherOrder);
} }
} }