Replaces .compareTo with Long.compare when possible

This commit is contained in:
Fuzzlemann 2017-07-23 13:51:54 +02:00
parent 8a90f60142
commit 5cf5eaf1ad
2 changed files with 6 additions and 10 deletions

View File

@ -5,9 +5,10 @@
*/
package main.java.com.djrapitops.plan.utilities.comparators;
import java.util.Comparator;
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
import java.util.Comparator;
/**
*
* @author Rsl1122
@ -16,7 +17,7 @@ public class HandlingInfoTimeComparator implements Comparator<HandlingInfo> {
@Override
public int compare(HandlingInfo o1, HandlingInfo o2) {
return ((Long) o1.getTime()).compareTo((Long) o2.getTime());
return Long.compare(o1.getTime(), o2.getTime());
}
}

View File

@ -1,8 +1,9 @@
package main.java.com.djrapitops.plan.utilities.comparators;
import java.util.Comparator;
import main.java.com.djrapitops.plan.data.SessionData;
import java.util.Comparator;
/**
*
* @author Rsl1122
@ -12,12 +13,6 @@ public class SessionDataComparator implements Comparator<SessionData> {
// This method should only be used if FactionsHook.isEnabled() returns true.
@Override
public int compare(SessionData s1, SessionData s2) {
if (s1.getSessionStart() == s2.getSessionStart()) {
return 0;
}
if (s1.getSessionStart() > s2.getSessionStart()) {
return 1;
}
return -1;
return Long.compare(s1.getSessionStart(), s2.getSessionStart());
}
}