Don’t apply function to optionals.
[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
34         /**
35          * Returns the Sone this image belongs to.
36          *
37          * @return The Sone this image belongs to
38          */
39         Sone getSone();
40
41         /**
42          * Returns the album this image belongs to.
43          *
44          * @return The album this image belongs to
45          */
46         Album getAlbum();
47
48         /**
49          * Returns the request key of this image.
50          *
51          * @return The request key of this image
52          */
53         String getKey();
54
55         /**
56          * Returns whether the image has already been inserted. An image is
57          * considered as having been inserted it its {@link #getKey() key} is not
58          * {@code null}.
59          *
60          * @return {@code true} if there is a key for this image, {@code false}
61          *         otherwise
62          */
63         boolean isInserted();
64
65         /**
66          * Returns the creation time of this image.
67          *
68          * @return The creation time of this image (in milliseconds since 1970, Jan
69          *         1, UTC)
70          */
71         long getCreationTime();
72
73         /**
74          * Returns the width of this image.
75          *
76          * @return The width of this image (in pixels)
77          */
78         int getWidth();
79
80         /**
81          * Returns the height of this image.
82          *
83          * @return The height of this image (in pixels)
84          */
85         int getHeight();
86
87         /**
88          * Returns the title of this image.
89          *
90          * @return The title of this image
91          */
92         String getTitle();
93
94         /**
95          * Returns the description of this image.
96          *
97          * @return The description of this image
98          */
99         String getDescription();
100
101         /**
102          * {@inheritDoc}
103          */
104         @Override
105         String getFingerprint();
106
107         Modifier modify() throws IllegalStateException;
108
109         interface Modifier {
110
111                 Modifier setKey(String key);
112
113                 Modifier setTitle(String title);
114
115                 Modifier setDescription(String description);
116
117                 Image update() throws IllegalStateException;
118
119         }
120
121 }