From: David ‘Bombe’ Roden Date: Mon, 1 Nov 2010 20:31:50 +0000 (+0100) Subject: Add name comparator. X-Git-Tag: 0.2-RC1~73 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ae4e57dd9d46d4514cb76a654e3ba5c1dc4aad6f;p=Sone.git Add name comparator. --- 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);