Add container for image data.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Image.java
1 /*
2  * Sone - Image.java - Copyright © 2011 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 import java.util.UUID;
21
22 /**
23  * Container for image metadata.
24  *
25  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
26  */
27 public class Image {
28
29         /** The ID of the image. */
30         private final String id;
31
32         /** The key of the image. */
33         private final String key;
34
35         /** The creation time of the image. */
36         private final long creationTime;
37
38         /** The width of the image. */
39         private final int width;
40
41         /** The height of the image. */
42         private final int height;
43
44         /** The title of the image. */
45         private String title;
46
47         /** The description of the image. */
48         private String description;
49
50         /**
51          * Creates a new image.
52          *
53          * @param key
54          *            The key of the image
55          * @param creationTime
56          *            The creation time of the image
57          * @param width
58          *            The width of the image
59          * @param height
60          *            The height of the image
61          */
62         public Image(String key, long creationTime, int width, int height) {
63                 this(UUID.randomUUID().toString(), key, creationTime, width, height);
64         }
65
66         /**
67          * Creates a new image.
68          *
69          * @param id
70          *            The ID of the image
71          * @param key
72          *            The key of the image
73          * @param creationTime
74          *            The creation time of the image
75          * @param width
76          *            The width of the image
77          * @param height
78          *            The height of the image
79          */
80         public Image(String id, String key, long creationTime, int width, int height) {
81                 this.id = id;
82                 this.key = key;
83                 this.creationTime = creationTime;
84                 this.width = width;
85                 this.height = height;
86         }
87
88         //
89         // ACCESSORS
90         //
91
92         /**
93          * Returns the ID of this image.
94          *
95          * @return The ID of this image
96          */
97         public String getId() {
98                 return id;
99         }
100
101         /**
102          * Returns the key of this image.
103          *
104          * @return The key of this image
105          */
106         public String getKey() {
107                 return key;
108         }
109
110         /**
111          * Returns the creation time of this image.
112          *
113          * @return The creation time of this image (in milliseconds since 1970, Jan
114          *         1, UTC)
115          */
116         public long getCreationTime() {
117                 return creationTime;
118         }
119
120         /**
121          * Returns the width of this image.
122          *
123          * @return The width of this image (in pixels)
124          */
125         public int getWidth() {
126                 return width;
127         }
128
129         /**
130          * Returns the height of this image.
131          *
132          * @return The height of this image (in pixels)
133          */
134         public int getHeight() {
135                 return height;
136         }
137
138         /**
139          * Returns the title of this image.
140          *
141          * @return The title of this image
142          */
143         public String getTitle() {
144                 return title;
145         }
146
147         /**
148          * Sets the title of this image.
149          *
150          * @param title
151          *            The title of this image
152          * @return This image
153          */
154         public Image setTitle(String title) {
155                 this.title = title;
156                 return this;
157         }
158
159         /**
160          * Returns the description of this image.
161          *
162          * @return The description of this image
163          */
164         public String getDescription() {
165                 return description;
166         }
167
168         /**
169          * Sets the description of this image.
170          *
171          * @param description
172          *            The description of this image
173          * @return This image
174          */
175         public Image setDescription(String description) {
176                 this.description = description;
177                 return this;
178         }
179
180 }