- /** 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) {
- int rightSoneImageCount = from(asList(rightSone.getRootAlbum())).transformAndConcat(FLATTENER).transformAndConcat(IMAGES).size();
- int leftSoneImageCount = from(asList(leftSone.getRootAlbum())).transformAndConcat(FLATTENER).transformAndConcat(IMAGES).size();
- /* sort descending. */
- return Ints.compare(rightSoneImageCount, leftSoneImageCount);
- }
- };
-
- public static final Function<Sone, List<Album>> toAllAlbums = new Function<Sone, List<Album>>() {
- @Override
- public List<Album> apply(@Nullable Sone sone) {
- return (sone == null) ? Collections.<Album>emptyList() : FLATTENER.apply(
- sone.getRootAlbum());
- }
- };
-
- public static final Function<Sone, List<Image>> toAllImages = new Function<Sone, List<Image>>() {
- @Override
- public List<Image> apply(@Nullable Sone sone) {
- return (sone == null) ? Collections.<Image>emptyList() :
- from(FLATTENER.apply(sone.getRootAlbum()))
- .transformAndConcat(IMAGES).toList();
- }
- };
-