Make Album implement Fingerprintable.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 1 Jan 2011 13:39:33 +0000 (14:39 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 1 Jan 2011 13:39:33 +0000 (14:39 +0100)
src/main/java/net/pterodactylus/sone/data/Album.java

index 62357d1..76015c8 100644 (file)
@@ -28,7 +28,7 @@ import net.pterodactylus.util.validation.Validation;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public class Album {
+public class Album implements Fingerprintable {
 
        /** The ID of this album. */
        private final String id;
@@ -240,6 +240,39 @@ public class Album {
        }
 
        //
+       // FINGERPRINTABLE METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public String getFingerprint() {
+               StringBuilder fingerprint = new StringBuilder();
+               fingerprint.append("Album(");
+               fingerprint.append("ID(").append(id).append(')');
+               fingerprint.append("Name(").append(name).append(')');
+               fingerprint.append("Description(").append(description).append(')');
+
+               /* add nested albums. */
+               fingerprint.append("Albums(");
+               for (Album album : albums) {
+                       fingerprint.append(album.getFingerprint());
+               }
+               fingerprint.append(')');
+
+               /* add images. */
+               fingerprint.append("Images(");
+               for (Image image : images) {
+                       fingerprint.append(image.getFingerprint());
+               }
+               fingerprint.append(')');
+
+               fingerprint.append(')');
+               return fingerprint.toString();
+       }
+
+       //
        // OBJECT METHODS
        //