From 55c7c1e4b98b06091b5053af4a9157e4a3428b32 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:07:41 +0200 Subject: [PATCH] =?utf8?q?Add=20comparator=20that=20uses=20the=20=E2=80=9C?= =?utf8?q?isArchive=E2=80=9D=20predicate.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../net/pterodactylus/xdcc/ui/stdin/CommandReader.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 95425d0..abef80e 100644 --- a/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java +++ b/src/main/java/net/pterodactylus/xdcc/ui/stdin/CommandReader.java @@ -330,6 +330,23 @@ public class CommandReader extends AbstractExecutionThreadService { }; /** + * {@link Comparator} for {@link Result}s that sorts archives (as per {@link + * #isArchive} to the back of the list. + */ + private static final Comparator packArchiveComparator = new Comparator() { + @Override + public int compare(Result leftResult, Result rightResult) { + if (isArchive.apply(leftResult) && !isArchive.apply(rightResult)) { + return 1; + } + if (!isArchive.apply(leftResult) && isArchive.apply(rightResult)) { + return -1; + } + return 0; + } + }; + + /** * {@link Comparator} for bot nicknames. It comprises different strategies: * one name pattern is preferred (and thus listed first), one pattern is * disliked (and thus listed last), the rest is sorted alphabetically. -- 2.7.4