From: David ‘Bombe’ Roden Date: Mon, 20 Jun 2011 05:52:43 +0000 (+0200) Subject: Add last activity comparator. X-Git-Tag: 0.6.6^2~70^2~1 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=192a3f41bcbf99fdb42213dc2680f9061ff64c40;p=Sone.git Add last activity comparator. --- diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index e1c0391..ca87856 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -60,6 +60,17 @@ public class Sone implements Fingerprintable, Comparable { }; + /** + * Comparator that sorts Sones by last activity (least recent active first). + */ + public static final Comparator LAST_ACTIVITY_COMPARATOR = new Comparator() { + + @Override + public int compare(Sone firstSone, Sone secondSone) { + return (int) Math.min(Integer.MAX_VALUE, Math.max(Integer.MIN_VALUE, secondSone.getTime() - firstSone.getTime())); + } + }; + /** Filter to remove Sones that have not been downloaded. */ public static final Filter EMPTY_SONE_FILTER = new Filter() {