- public Album moveAlbumUp(Album album) {
- checkNotNull(album, "album must not be null");
- checkArgument(album.getSone().equals(sone), "album must belong to the same Sone as this album");
- checkArgument(equals(album.getParent()), "album must belong to this album");
- int oldIndex = albums.indexOf(album);
- if (oldIndex <= 0) {
- return null;
- }
- albums.remove(oldIndex);
- albums.add(oldIndex - 1, album);
- return albums.get(oldIndex);
- }
-
- @Override
- public Album moveAlbumDown(Album album) {
- checkNotNull(album, "album must not be null");
- checkArgument(album.getSone().equals(sone), "album must belong to the same Sone as this 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;
- }
- albums.remove(oldIndex);
- albums.add(oldIndex + 1, album);
- return albums.get(oldIndex);
- }
-
- @Override