From 129815864bbd3cf5ce221eac24e29e2d0e9df036 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 1 Jan 2011 13:47:50 +0100 Subject: [PATCH] Add ID to album. --- .../java/net/pterodactylus/sone/data/Album.java | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) 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); + } + } -- 2.7.4