From ae4e57dd9d46d4514cb76a654e3ba5c1dc4aad6f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 1 Nov 2010 21:31:50 +0100 Subject: [PATCH] Add name comparator. --- src/main/java/net/pterodactylus/sone/data/Sone.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 5c0e486..95c7a27 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -41,6 +41,20 @@ import freenet.keys.FreenetURI; */ public class Sone { + /** comparator that sorts Sones by their nice name. */ + public static final Comparator NICE_NAME_COMPARATOR = new Comparator() { + + @Override + public int compare(Sone leftSone, Sone rightSone) { + int diff = SoneAccessor.getNiceName(leftSone).compareToIgnoreCase(SoneAccessor.getNiceName(rightSone)); + if (diff != 0) { + return diff; + } + return leftSone.getId().compareToIgnoreCase(rightSone.getId()); + } + + }; + /** The logger. */ private static final Logger logger = Logging.getLogger(Sone.class); -- 2.7.4