2 * Sone - Image.java - Copyright © 2011 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sone.data;
20 import java.util.UUID;
22 import net.pterodactylus.util.validation.Validation;
25 * Container for image metadata.
27 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
31 /** The ID of the image. */
32 private final String id;
34 /** The Sone the image belongs to. */
35 private final Sone sone;
37 /** The key of the image. */
38 private final String key;
40 /** The creation time of the image. */
41 private final long creationTime;
43 /** The width of the image. */
44 private final int width;
46 /** The height of the image. */
47 private final int height;
49 /** The title of the image. */
52 /** The description of the image. */
53 private String description;
56 * Creates a new image.
59 * The Sone the image belongs to
61 * The key of the image
63 * The creation time of the image
65 * The width of the image
67 * The height of the image
69 public Image(Sone sone, String key, long creationTime, int width, int height) {
70 this(UUID.randomUUID().toString(), sone, key, creationTime, width, height);
74 * Creates a new image.
79 * The Sone the image belongs to
81 * The key of the image
83 * The creation time of the image
85 * The width of the image
87 * The height of the image
89 public Image(String id, Sone sone, String key, long creationTime, int width, int height) {
90 Validation.begin().isNotNull("Image ID", id).isNotNull("Image Owner", sone).isNotNull("Image Key", key).isGreater("Image Creation Time", creationTime, 0).isGreater("Image Width", width, 0).isGreater("Image Height", height, 0).check();
94 this.creationTime = creationTime;
104 * Returns the ID of this image.
106 * @return The ID of this image
108 public String getId() {
113 * Returns the Sone this image belongs to.
115 * @return The Sone this image belongs to
117 public Sone getSone() {
122 * Returns the key of this image.
124 * @return The key of this image
126 public String getKey() {
131 * Returns the creation time of this image.
133 * @return The creation time of this image (in milliseconds since 1970, Jan
136 public long getCreationTime() {
141 * Returns the width of this image.
143 * @return The width of this image (in pixels)
145 public int getWidth() {
150 * Returns the height of this image.
152 * @return The height of this image (in pixels)
154 public int getHeight() {
159 * Returns the title of this image.
161 * @return The title of this image
163 public String getTitle() {
168 * Sets the title of this image.
171 * The title of this image
174 public Image setTitle(String title) {
175 Validation.begin().isNotNull("Image Title", title).check();
181 * Returns the description of this image.
183 * @return The description of this image
185 public String getDescription() {
190 * Sets the description of this image.
193 * The description of this image
196 public Image setDescription(String description) {
197 Validation.begin().isNotNull("Image Description", description).check();
198 this.description = description;