Fixed comparator method contract when date is null

This commit is contained in:
ByteHamster 2020-11-11 22:43:27 +01:00
parent e67e5a35be
commit cabe1a0f66
1 changed files with 5 additions and 1 deletions

View File

@ -14,8 +14,12 @@ public class FeedItemPubdateComparator implements Comparator<FeedItem> {
*/ */
@Override @Override
public int compare(FeedItem lhs, FeedItem rhs) { public int compare(FeedItem lhs, FeedItem rhs) {
if (rhs.getPubDate() == null || lhs.getPubDate() == null) { if (rhs.getPubDate() == null && lhs.getPubDate() == null) {
return 0; return 0;
} else if (rhs.getPubDate() == null) {
return 1;
} else if (lhs.getPubDate() == null) {
return -1;
} }
return rhs.getPubDate().compareTo(lhs.getPubDate()); return rhs.getPubDate().compareTo(lhs.getPubDate());
} }