Return original album when it can’t be moved
[Sone.git] / src / main / java / net / pterodactylus / sone / data / impl / AlbumImpl.java
index c569e0a..3488577 100644 (file)
@@ -134,7 +134,7 @@ public class AlbumImpl implements Album {
                checkArgument(equals(album.getParent()), "album must belong to this album");
                int oldIndex = albums.indexOf(album);
                if (oldIndex <= 0) {
-                       return null;
+                       return album;
                }
                albums.remove(oldIndex);
                albums.add(oldIndex - 1, album);
@@ -148,7 +148,7 @@ public class AlbumImpl implements Album {
                checkArgument(equals(album.getParent()), "album must belong to this album");
                int oldIndex = albums.indexOf(album);
                if ((oldIndex < 0) || (oldIndex >= (albums.size() - 1))) {
-                       return null;
+                       return album;
                }
                albums.remove(oldIndex);
                albums.add(oldIndex + 1, album);
@@ -209,7 +209,7 @@ public class AlbumImpl implements Album {
                checkArgument(image.getAlbum().equals(this), "image must belong to this album");
                int oldIndex = imageIds.indexOf(image.getId());
                if (oldIndex <= 0) {
-                       return null;
+                       return image;
                }
                imageIds.remove(image.getId());
                imageIds.add(oldIndex - 1, image.getId());
@@ -224,7 +224,7 @@ public class AlbumImpl implements Album {
                checkArgument(image.getAlbum().equals(this), "image must belong to this album");
                int oldIndex = imageIds.indexOf(image.getId());
                if ((oldIndex == -1) || (oldIndex >= (imageIds.size() - 1))) {
-                       return null;
+                       return image;
                }
                imageIds.remove(image.getId());
                imageIds.add(oldIndex + 1, image.getId());