X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FImage.java;h=55b0094465e43cea9362c1f05bb0b3c1f67e5451;hb=6cac5513ec98c44bc574a87111bec2a2524464bd;hp=cae25207ba98238510a5b99e8da35c2c06923fcd;hpb=a2724d76b5ac2499e16d18747b216695ed020fa6;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 cae2520..55b0094 100644
--- a/src/main/java/net/pterodactylus/sone/data/Image.java
+++ b/src/main/java/net/pterodactylus/sone/data/Image.java
@@ -1,5 +1,5 @@
/*
- * Sone - Image.java - Copyright © 2011 David Roden
+ * Sone - Image.java - Copyright © 2011â2016 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,95 +17,60 @@
package net.pterodactylus.sone.data;
-import java.util.UUID;
-
/**
* Container for image metadata.
*
- * @author David âBombeâ Roden
+ * @author David Roden
*/
-public class Image {
-
- /** The ID of the image. */
- private final String id;
-
- /** The key of the image. */
- private final String key;
-
- /** The creation time of the image. */
- private final long creationTime;
-
- /** The width of the image. */
- private final int width;
-
- /** The height of the image. */
- private final int height;
+public interface Image extends Identified, Fingerprintable {
- /** The title of the image. */
- private String title;
-
- /** The description of the image. */
- private String description;
+ /**
+ * Returns the ID of this image.
+ *
+ * @return The ID of this image
+ */
+ String getId();
/**
- * Creates a new image.
+ * Returns the Sone this image belongs to.
*
- * @param key
- * The key of the image
- * @param creationTime
- * The creation time of the image
- * @param width
- * The width of the image
- * @param height
- * The height of the image
+ * @return The Sone this image belongs to
*/
- public Image(String key, long creationTime, int width, int height) {
- this(UUID.randomUUID().toString(), key, creationTime, width, height);
- }
+ Sone getSone();
/**
- * Creates a new image.
+ * Returns the album this image belongs to.
*
- * @param id
- * The ID of the image
- * @param key
- * The key of the image
- * @param creationTime
- * The creation time of the image
- * @param width
- * The width of the image
- * @param height
- * The height of the image
+ * @return The album this image belongs to
*/
- public Image(String id, String key, long creationTime, int width, int height) {
- this.id = id;
- this.key = key;
- this.creationTime = creationTime;
- this.width = width;
- this.height = height;
- }
+ Album getAlbum();
- //
- // ACCESSORS
- //
+ /**
+ * 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
+ */
+ Image setAlbum(Album album);
/**
- * Returns the ID of this image.
+ * Returns the request key of this image.
*
- * @return The ID of this image
+ * @return The request key of this image
*/
- public String getId() {
- return id;
- }
+ String getKey();
/**
- * Returns the key of this image.
+ * 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 The key of this image
+ * @return {@code true} if there is a key for this image, {@code false}
+ * otherwise
*/
- public String getKey() {
- return key;
- }
+ boolean isInserted();
/**
* Returns the creation time of this image.
@@ -113,68 +78,64 @@ public class Image {
* @return The creation time of this image (in milliseconds since 1970, Jan
* 1, UTC)
*/
- public long getCreationTime() {
- return creationTime;
- }
+ long getCreationTime();
/**
* Returns the width of this image.
*
* @return The width of this image (in pixels)
*/
- public int getWidth() {
- return width;
- }
+ int getWidth();
/**
* Returns the height of this image.
*
* @return The height of this image (in pixels)
*/
- public int getHeight() {
- return height;
- }
+ int getHeight();
/**
* Returns the title of this image.
*
* @return The title of this image
*/
- public String getTitle() {
- return title;
- }
-
- /**
- * Sets the title of this image.
- *
- * @param title
- * The title of this image
- * @return This image
- */
- public Image setTitle(String title) {
- this.title = title;
- return this;
- }
+ String getTitle();
/**
* Returns the description of this image.
*
* @return The description of this image
*/
- public String getDescription() {
- return description;
- }
+ String getDescription();
/**
- * Sets the description of this image.
- *
- * @param description
- * The description of this image
- * @return This image
+ * {@inheritDoc}
*/
- public Image setDescription(String description) {
- this.description = description;
- return this;
+ @Override
+ String getFingerprint();
+
+ Modifier modify() throws IllegalStateException;
+
+ interface Modifier {
+
+ Modifier setSone(Sone sone);
+
+ Modifier setCreationTime(long creationTime);
+
+ Modifier setKey(String key);
+
+ Modifier setTitle(String title);
+
+ Modifier setDescription(String description);
+
+ Modifier setWidth(int width);
+
+ Modifier setHeight(int height);
+
+ Image update() throws IllegalStateException;
+
+ class ImageTitleMustNotBeEmpty extends IllegalStateException { }
+
}
}