From: David ‘Bombe’ Roden Date: Thu, 8 Aug 2013 00:09:30 +0000 (+0200) Subject: Chain the three comparators. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=2d0f3614a96b0d8f7d5666c65ab80b3cbf5349ec;p=xudocci.git Chain the three comparators. --- diff --git a/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java b/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java index 7b6e64f..9cd2a12 100644 --- a/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java +++ b/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java @@ -43,6 +43,7 @@ import net.pterodactylus.xdcc.data.Download; import net.pterodactylus.xdcc.data.Pack; import com.google.common.base.Predicate; +import com.google.common.collect.ComparisonChain; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.eventbus.Subscribe; @@ -439,14 +440,10 @@ public class CommandReader extends AbstractExecutionThreadService { @Override public int compareTo(Result result) { - if (isArchive.apply(this) && !isArchive.apply(result)) { - return 1; - } - if (!isArchive.apply(this) && isArchive.apply(result)) { - return -1; - } - /* sort by bot name. */ - return botNameComparator.compare(bot().name(), result.bot().name()); + return ComparisonChain.start() + .compare(this, result, packArchiveComparator) + .compare(this, result, botNameComparator) + .compare(this, result, packNameComparator).result(); } }