Fix: boxed primitive for compare

[Broken Window Theory] As per current SpotBugs report, replace all usages
of boxed Long.compareTo(Long) with Long.compare(long, long)
This commit is contained in:
Luca Santarelli 2021-08-08 23:22:00 +02:00
parent 092b605b4a
commit f4597d879a
3 changed files with 5 additions and 11 deletions

View file

@ -60,8 +60,7 @@ public class FileSortOrderByDate extends FileSortOrder {
final int multiplier = isAscending ? 1 : -1;
Collections.sort(files, (o1, o2) -> {
Long obj1 = o1.getDeletionTimestamp();
return multiplier * obj1.compareTo(o2.getDeletionTimestamp());
return multiplier * Long.compare(o1.getDeletionTimestamp(),o2.getDeletionTimestamp());
});
return super.sortTrashbinFiles(files);

View file

@ -55,8 +55,7 @@ public class FileSortOrderBySize extends FileSortOrder {
} else if (o2.isFolder()) {
return 1;
} else {
Long obj1 = o1.getFileLength();
return multiplier * obj1.compareTo(o2.getFileLength());
return multiplier * Long.compare(o1.getFileLength(),o2.getFileLength());
}
});
@ -82,8 +81,7 @@ public class FileSortOrderBySize extends FileSortOrder {
} else if (o2.isFolder()) {
return 1;
} else {
Long obj1 = o1.getFileLength();
return multiplier * obj1.compareTo(o2.getFileLength());
return multiplier * Long.compare(o1.getFileLength(),o2.getFileLength());
}
});
@ -108,8 +106,7 @@ public class FileSortOrderBySize extends FileSortOrder {
} else if (o2.isDirectory()) {
return 1;
} else {
Long obj1 = o1.length();
return multiplier * obj1.compareTo(o2.length());
return multiplier * Long.compare(o1.length(),o2.length());
}
});

View file

@ -262,9 +262,7 @@ public final class FileStorageUtils {
public static List<OCFile> sortOcFolderDescDateModifiedWithoutFavoritesFirst(List<OCFile> files) {
final int multiplier = -1;
Collections.sort(files, (o1, o2) -> {
@SuppressFBWarnings(value = "Bx", justification = "Would require stepping up API level")
Long obj1 = o1.getModificationTimestamp();
return multiplier * obj1.compareTo(o2.getModificationTimestamp());
return multiplier * Long.compare(o1.getModificationTimestamp(),o2.getModificationTimestamp());
});
return files;