- public Modifier modify() throws IllegalStateException {
- // TODO: reenable check for local images
- return new Modifier() {
- private Optional<String> key = absent();
- private Optional<String> title = absent();
- private Optional<String> description = absent();
-
- @Override
- public Modifier setKey(String key) {
- this.key = fromNullable(key);
- return this;
- }
-
- @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 Image update() throws IllegalStateException {
- checkState(!key.isPresent() || (DefaultImage.this.key == null), "key can not be changed");
-
- if (key.isPresent()) {
- DefaultImage.this.key = key.get();
- }
- if (title.isPresent()) {
- DefaultImage.this.title = title.get();
- }
- if (description.isPresent()) {
- DefaultImage.this.description = description.get();
- }
-
- return DefaultImage.this;
+ public void remove() throws IllegalStateException {
+ synchronized (album) {
+ album.images.remove(getId());
+ album.imageIds.remove(getId());
+ if (getId().equals(album.albumImage)) {
+ album.albumImage = from(album.images.values()).transform(GET_ID).first().orNull();