+ /** Comparator that sorts bots with running downloads to the back of the list. */
+ private final Comparator<Result> botsWithRunningTransfersComparator = new Comparator<Result>() {
+ @Override
+ public int compare(Result leftResult, Result rightResult) {
+ Collection<Bot> botsWithTransfers = from(core.downloads()).transform(new Function<Download, Bot>() {
+ @Override
+ public Bot apply(Download download) {
+ return download.bot();
+ }
+ }).toSet();
+ boolean leftDownloading = botsWithTransfers.contains(leftResult.bot());
+ boolean rightDownloading = botsWithTransfers.contains(rightResult.bot());
+ if (leftDownloading && !rightDownloading) {
+ return 1;
+ }
+ if (!leftDownloading && rightDownloading) {
+ return -1;
+ }
+ return 0;
+ }
+ };
+
+ /** The core. */
+ private final Core core;
+