Change some validations to allow moving images.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Apr 2011 04:53:09 +0000 (06:53 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Apr 2011 04:53:09 +0000 (06:53 +0200)
src/main/java/net/pterodactylus/sone/data/Album.java
src/main/java/net/pterodactylus/sone/data/Image.java

index 5d4eeb7..0abc59c 100644 (file)
@@ -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;
        }
index 151f252..e71fa3d 100644 (file)
@@ -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;
        }