From: David ‘Bombe’ Roden Date: Sat, 1 Jan 2011 12:47:50 +0000 (+0100) Subject: Add ID to album. X-Git-Tag: beta-freefall-0.6.2-1~151 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=129815864bbd3cf5ce221eac24e29e2d0e9df036;p=Sone.git Add ID to album. --- diff --git a/src/main/java/net/pterodactylus/sone/data/Album.java b/src/main/java/net/pterodactylus/sone/data/Album.java index 2055755..919f797 100644 --- a/src/main/java/net/pterodactylus/sone/data/Album.java +++ b/src/main/java/net/pterodactylus/sone/data/Album.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.data; import java.util.ArrayList; import java.util.List; +import java.util.UUID; /** * Container for images that can also contain nested {@link Album}s. @@ -27,6 +28,9 @@ import java.util.List; */ public class Album { + /** The ID of this album. */ + private final String id; + /** Nested albums. */ private final List albums = new ArrayList(); @@ -39,11 +43,37 @@ public class Album { /** The description of this album. */ private String description; + /** + * Creates a new album with a random ID. + */ + public Album() { + this(UUID.randomUUID().toString()); + } + + /** + * Creates a new album with the given ID. + * + * @param id + * The ID of the album + */ + public Album(String id) { + this.id = id; + } + // // ACCESSORS // /** + * Returns the ID of this album. + * + * @return The ID of this album + */ + public String getId() { + return id; + } + + /** * Returns the nested albums. * * @return The nested albums @@ -103,4 +133,20 @@ public class Album { return this; } + // + // OBJECT METHODS + // + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object object) { + if (!(object instanceof Album)) { + return false; + } + Album album = (Album) object; + return id.equals(album.id); + } + }