X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FImage.java;h=d6e7114c338cc57d4d2f27f10fd240528ad0b6f4;hb=2b400308146190305dde0778627cd138fe2a0d0b;hp=2afb0983694e727b3f04582ef52113ea7eaccb39;hpb=443400257166817e417a67c6e2630a540b1fa075;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/data/Image.java b/src/main/java/net/pterodactylus/sone/data/Image.java index 2afb098..d6e7114 100644 --- a/src/main/java/net/pterodactylus/sone/data/Image.java +++ b/src/main/java/net/pterodactylus/sone/data/Image.java @@ -34,6 +34,9 @@ public class Image implements Fingerprintable { /** The Sone the image belongs to. */ private Sone sone; + /** The album this image belongs to. */ + private Album album; + /** The request key of the image. */ private String key; @@ -108,6 +111,29 @@ public class Image implements Fingerprintable { } /** + * Returns the album this image belongs to. + * + * @return The album this image belongs to + */ + public Album getAlbum() { + return album; + } + + /** + * Sets the album this image belongs to. The album of an image can only be + * set once, and it is usually called by {@link Album#addImage(Image)}. + * + * @param album + * The album this image belongs to + * @return This image + */ + public Image setAlbum(Album album) { + Validation.begin().isNull("Current Album", this.album).isNotNull("New Album", album).check().isEqual("Album Owner and Image Owner", album.getSone(), getSone()).check(); + this.album = album; + return this; + } + + /** * Returns the request key of this image. * * @return The request key of this image @@ -131,6 +157,18 @@ public class Image implements Fingerprintable { } /** + * Returns whether the image has already been inserted. An image is + * considered as having been inserted it its {@link #getKey() key} is not + * {@code null}. + * + * @return {@code true} if there is a key for this image, {@code false} + * otherwise + */ + public boolean isInserted() { + return key != null; + } + + /** * Returns the creation time of this image. * * @return The creation time of this image (in milliseconds since 1970, Jan