- public Modifier modify() throws IllegalStateException {
- // TODO: reenable check for local Sones
- return new Modifier() {
- private Optional<String> title = absent();
-
- private Optional<String> description = absent();
-
- private Optional<String> albumImage = absent();
-
- @Override
- public Modifier setTitle(String title) {
- this.title = fromNullable(title);
- return this;
- }
-
- @Override
- public Modifier setDescription(String description) {
- this.description = fromNullable(description);
- return this;
- }
-
- @Override
- public Modifier setAlbumImage(String imageId) {
- this.albumImage = fromNullable(imageId);
- return this;
- }
-
- @Override
- public Album update() throws IllegalStateException {
- if (title.isPresent()) {
- DefaultAlbum.this.title = title.get();
- }
- if (description.isPresent()) {
- DefaultAlbum.this.description = description.get();
- }
- if (albumImage.isPresent()) {
- DefaultAlbum.this.albumImage = albumImage.get();
- }
- return DefaultAlbum.this;
- }
- };
+ public void remove() throws IllegalStateException {
+ checkState(!isRoot(), "can not remove root album");
+ removeAllAlbums();
+ removeAllImages();
+ parent.albums.remove(this);