From 9418b7209b46bd5cbda6006ac00f855df2d383a4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 14 Apr 2011 06:53:09 +0200 Subject: [PATCH] Change some validations to allow moving images. --- src/main/java/net/pterodactylus/sone/data/Album.java | 5 ++--- src/main/java/net/pterodactylus/sone/data/Image.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/data/Album.java b/src/main/java/net/pterodactylus/sone/data/Album.java index 5d4eeb7..0abc59c 100644 --- a/src/main/java/net/pterodactylus/sone/data/Album.java +++ b/src/main/java/net/pterodactylus/sone/data/Album.java @@ -103,7 +103,7 @@ public class Album implements Fingerprintable { * @return This album */ public Album setSone(Sone sone) { - Validation.begin().isNotNull("New Album Owner", sone).check(); + Validation.begin().isNotNull("New Album Owner", sone).isEither("Old Album Owner", this.sone, null, sone).check(); this.sone = sone; return this; } @@ -124,7 +124,7 @@ public class Album implements Fingerprintable { * The album to add */ public void addAlbum(Album album) { - Validation.begin().isNotNull("Album", album).check().isEqual("Album Owner", album.sone, sone).isNull("Album Parent", album.parent).check(); + Validation.begin().isNotNull("Album", album).check().isEqual("Album Owner", album.sone, sone).isEither("Old Album Parent", this.parent, null, album.parent).check(); albums.add(album); album.setParent(this); } @@ -226,7 +226,6 @@ public class Album implements Fingerprintable { * @return This album */ protected Album removeParent() { - Validation.begin().isNotNull("Album Parent", parent).check(); this.parent = null; return this; } diff --git a/src/main/java/net/pterodactylus/sone/data/Image.java b/src/main/java/net/pterodactylus/sone/data/Image.java index 151f252..e71fa3d 100644 --- a/src/main/java/net/pterodactylus/sone/data/Image.java +++ b/src/main/java/net/pterodactylus/sone/data/Image.java @@ -128,7 +128,7 @@ public class Image implements Fingerprintable { * @return This image */ public Image setAlbum(Album album) { - Validation.begin().isNotNull("New Album", album).isEither("Old Album", this.album, null, album).check().isEqual("Album Owner and Image Owner", album.getSone(), getSone()).check(); + Validation.begin().isNotNull("New Album", album).check().isEqual("Album Owner and Image Owner", album.getSone(), getSone()).check(); this.album = album; return this; } -- 2.7.4