From 2d0f3614a96b0d8f7d5666c65ab80b3cbf5349ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 8 Aug 2013 02:09:30 +0200 Subject: [PATCH] Chain the three comparators. --- .../java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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(); } } -- 2.7.4