Replace conditional with compare method

This commit is contained in:
Andrew Rabert 2018-04-24 19:58:58 -04:00
parent bb9e3a506e
commit 82a8d0fff8
2 changed files with 4 additions and 28 deletions

View File

@ -228,31 +228,13 @@ public class OfflineMusicService implements MusicService {
}
Collections.sort(artists, (lhs, rhs) -> {
if (lhs.getCloseness() == rhs.getCloseness()) {
return 0;
} else if (lhs.getCloseness() > rhs.getCloseness()) {
return -1;
} else {
return 1;
}
return Integer.compare(rhs.getCloseness(), lhs.getCloseness());
});
Collections.sort(albums, (lhs, rhs) -> {
if (lhs.getCloseness() == rhs.getCloseness()) {
return 0;
} else if (lhs.getCloseness() > rhs.getCloseness()) {
return -1;
} else {
return 1;
}
return Integer.compare(rhs.getCloseness(), lhs.getCloseness());
});
Collections.sort(songs, (lhs, rhs) -> {
if (lhs.getCloseness() == rhs.getCloseness()) {
return 0;
} else if (lhs.getCloseness() > rhs.getCloseness()) {
return -1;
} else {
return 1;
}
return Integer.compare(rhs.getCloseness(), lhs.getCloseness());
});
// Respect counts in search criteria

View File

@ -136,13 +136,7 @@ public class CacheCleaner {
private void sortByAscendingModificationTime(List<File> files) {
Collections.sort(files, (a, b) -> {
if (a.lastModified() < b.lastModified()) {
return -1;
}
if (a.lastModified() > b.lastModified()) {
return 1;
}
return 0;
return Long.compare(a.lastModified(), b.lastModified());
});
}