Add album title comparator.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 21 Nov 2011 17:52:53 +0000 (18:52 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 21 Nov 2011 17:52:53 +0000 (18:52 +0100)
src/main/java/net/pterodactylus/sone/data/Album.java

index b15bc00..0bdf3a9 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.data;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -35,6 +36,15 @@ import net.pterodactylus.util.validation.Validation;
  */
 public class Album implements Fingerprintable {
 
+       /** Compares two {@link Album}s by {@link #getTitle()}. */
+       public static final Comparator<Album> TITLE_COMPARATOR = new Comparator<Album>() {
+
+               @Override
+               public int compare(Album leftAlbum, Album rightAlbum) {
+                       return leftAlbum.getTitle().compareToIgnoreCase(rightAlbum.getTitle());
+               }
+       };
+
        /** The ID of this album. */
        private final String id;