f2ef88d94d21e33a17c52ba52e832659f75c3480
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Image.java
1 /*
2  * Sone - Image.java - Copyright © 2011–2013 David Roden
3  *
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.
8  *
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.
13  *
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/>.
16  */
17
18 package net.pterodactylus.sone.data;
19
20 /**
21  * Container for image metadata.
22  *
23  * @author <a href="mailto:d.roden@xplosion.de">David Roden</a>
24  */
25 public interface Image extends Identified, Fingerprintable {
26
27         /**
28          * Returns the ID of this image.
29          *
30          * @return The ID of this image
31          */
32         String getId();
33         String getInternalId();
34
35         /**
36          * Returns the Sone this image belongs to.
37          *
38          * @return The Sone this image belongs to
39          */
40         Sone getSone();
41
42         /**
43          * Returns the album this image belongs to.
44          *
45          * @return The album this image belongs to
46          */
47         Album getAlbum();
48
49         /**
50          * Sets the album this image belongs to. The album of an image can only be
51          * set once, and it is usually called by {@link Album#addImage(Image)}.
52          *
53          * @param album
54          *            The album this image belongs to
55          * @return This image
56          */
57         Image setAlbum(Album album);
58
59         /**
60          * Returns the request key of this image.
61          *
62          * @return The request key of this image
63          */
64         String getKey();
65
66         /**
67          * Returns whether the image has already been inserted. An image is
68          * considered as having been inserted it its {@link #getKey() key} is not
69          * {@code null}.
70          *
71          * @return {@code true} if there is a key for this image, {@code false}
72          *         otherwise
73          */
74         boolean isInserted();
75
76         /**
77          * Returns the creation time of this image.
78          *
79          * @return The creation time of this image (in milliseconds since 1970, Jan
80          *         1, UTC)
81          */
82         long getCreationTime();
83
84         /**
85          * Returns the width of this image.
86          *
87          * @return The width of this image (in pixels)
88          */
89         int getWidth();
90
91         /**
92          * Returns the height of this image.
93          *
94          * @return The height of this image (in pixels)
95          */
96         int getHeight();
97
98         /**
99          * Returns the title of this image.
100          *
101          * @return The title of this image
102          */
103         String getTitle();
104
105         /**
106          * Returns the description of this image.
107          *
108          * @return The description of this image
109          */
110         String getDescription();
111
112         /**
113          * {@inheritDoc}
114          */
115         @Override
116         String getFingerprint();
117
118         Modifier modify() throws IllegalStateException;
119
120         interface Modifier {
121
122                 Modifier setSone(Sone sone);
123
124                 Modifier setCreationTime(long creationTime);
125
126                 Modifier setKey(String key);
127
128                 Modifier setTitle(String title);
129
130                 Modifier setDescription(String description);
131
132                 Modifier setWidth(int width);
133
134                 Modifier setHeight(int height);
135
136                 Image update() throws IllegalStateException;
137
138                 class ImageTitleMustNotBeEmpty extends IllegalStateException { }
139
140         }
141
142 }