X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FImageImpl.java;h=df901b02b3df65821bcbbd54f7440017469c978c;hb=4b9052a10d998339deec2f9b567d2913a9442f8b;hp=c8f7a9bb7549fe37cc69b44d323216e655723133;hpb=518efffdab386d47882aedee35031e66852c2772;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/data/ImageImpl.java b/src/main/java/net/pterodactylus/sone/data/ImageImpl.java index c8f7a9b..df901b0 100644 --- a/src/main/java/net/pterodactylus/sone/data/ImageImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/ImageImpl.java @@ -202,23 +202,43 @@ public class ImageImpl implements Image { @Override public Image update() throws IllegalStateException { checkState(!sone.isPresent() || (ImageImpl.this.sone == null) || sone.get().equals(ImageImpl.this.sone), "can not change Sone once set"); - checkState(!creationTime.isPresent() || (ImageImpl.this.creationTime == 0), "can not change creation time once set"); + checkState(!creationTime.isPresent() || ((ImageImpl.this.creationTime == 0) || (ImageImpl.this.creationTime == creationTime.get())), "can not change creation time once set"); checkState(!key.isPresent() || (ImageImpl.this.key == null) || key.get().equals(ImageImpl.this.key), "can not change key once set"); + if (title.isPresent() && title.get().trim().isEmpty()) { + throw new ImageTitleMustNotBeEmpty(); + } checkState(!width.isPresent() || (ImageImpl.this.width == 0) || width.get().equals(ImageImpl.this.width), "can not change width once set"); checkState(!height.isPresent() || (ImageImpl.this.height == 0) || height.get().equals(ImageImpl.this.height), "can not change height once set"); - ImageImpl.this.sone = sone.or(ImageImpl.this.sone); - ImageImpl.this.creationTime = creationTime.or(ImageImpl.this.creationTime); - ImageImpl.this.key = key.or(ImageImpl.this.key); - ImageImpl.this.title = title.or(ImageImpl.this.title); - ImageImpl.this.description = description.or(ImageImpl.this.description); - ImageImpl.this.width = width.or(ImageImpl.this.width); - ImageImpl.this.height = height.or(ImageImpl.this.height); + + if (sone.isPresent()) { + ImageImpl.this.sone = sone.get(); + } + if (creationTime.isPresent()) { + ImageImpl.this.creationTime = creationTime.get(); + } + if (key.isPresent()) { + ImageImpl.this.key = key.get(); + } + if (title.isPresent()) { + ImageImpl.this.title = title.get(); + } + if (description.isPresent()) { + ImageImpl.this.description = description.get(); + } + if (width.isPresent()) { + ImageImpl.this.width = width.get(); + } + if (height.isPresent()) { + ImageImpl.this.height = height.get(); + } return ImageImpl.this; } }; } + public static class ImageTitleMustNotBeEmpty extends IllegalStateException { } + // // FINGERPRINTABLE METHODS //