Add Sone comparator by image count.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 30 Sep 2011 12:56:55 +0000 (14:56 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 30 Sep 2011 12:56:55 +0000 (14:56 +0200)
src/main/java/net/pterodactylus/sone/data/Sone.java

index 1db47c2..ca970c2 100644 (file)
@@ -84,6 +84,18 @@ public class Sone implements Fingerprintable, Comparable<Sone> {
                }
        };
 
+       /** Comparator that sorts Sones by number of images (descending). */
+       public static final Comparator<Sone> IMAGE_COUNT_COMPARATOR = new Comparator<Sone>() {
+
+               /**
+                * {@inheritDoc}
+                */
+               @Override
+               public int compare(Sone leftSone, Sone rightSone) {
+                       return rightSone.getAllImages().size() - leftSone.getAllImages().size();
+               }
+       };
+
        /** Filter to remove Sones that have not been downloaded. */
        public static final Filter<Sone> EMPTY_SONE_FILTER = new Filter<Sone>() {