From 92230f170b37ac854ae07c43d04ab4ec0df163f9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 10 Jan 2011 20:32:25 +0100 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20require=20an=20owner.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/data/Album.java | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/data/Album.java b/src/main/java/net/pterodactylus/sone/data/Album.java index 76015c8..60fb296 100644 --- a/src/main/java/net/pterodactylus/sone/data/Album.java +++ b/src/main/java/net/pterodactylus/sone/data/Album.java @@ -34,7 +34,7 @@ public class Album implements Fingerprintable { private final String id; /** The Sone this album belongs to. */ - private final Sone sone; + private Sone sone; /** Nested albums. */ private final List albums = new ArrayList(); @@ -53,12 +53,9 @@ public class Album implements Fingerprintable { /** * Creates a new album with a random ID. - * - * @param sone - * The Sone this album belongs to */ - public Album(Sone sone) { - this(UUID.randomUUID().toString(), sone); + public Album() { + this(UUID.randomUUID().toString()); } /** @@ -66,13 +63,10 @@ public class Album implements Fingerprintable { * * @param id * The ID of the album - * @param sone - * The Sone this album belongs to */ - public Album(String id, Sone sone) { - Validation.begin().isNotNull("Album ID", id).isNotNull("Album Owner", sone).check(); + public Album(String id) { + Validation.begin().isNotNull("Album ID", id).check(); this.id = id; - this.sone = sone; } // @@ -98,6 +92,20 @@ public class Album implements Fingerprintable { } /** + * Sets the owner of the album. The owner can only be set as long as the + * current owner is {@code null}. + * + * @param sone + * The album owner + * @return This album + */ + public Album setSone(Sone sone) { + Validation.begin().isNull("Current Album Owner", this.sone).isNotNull("New Album Owner", sone).check().isEqual("New Album Owner", sone, this.sone).check(); + this.sone = sone; + return this; + } + + /** * Returns the nested albums. * * @return The nested albums @@ -285,7 +293,7 @@ public class Album implements Fingerprintable { return false; } Album album = (Album) object; - return sone.equals(album.sone) && id.equals(album.id); + return id.equals(album.id); } } -- 2.7.4