Add ID to album.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Album.java
1 /*
2  * Sone - Album.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.ArrayList;
21 import java.util.List;
22 import java.util.UUID;
23
24 /**
25  * Container for images that can also contain nested {@link Album}s.
26  *
27  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
28  */
29 public class Album {
30
31         /** The ID of this album. */
32         private final String id;
33
34         /** Nested albums. */
35         private final List<Album> albums = new ArrayList<Album>();
36
37         /** The images in this album. */
38         private final List<Image> images = new ArrayList<Image>();
39
40         /** The name of this album. */
41         private String name;
42
43         /** The description of this album. */
44         private String description;
45
46         /**
47          * Creates a new album with a random ID.
48          */
49         public Album() {
50                 this(UUID.randomUUID().toString());
51         }
52
53         /**
54          * Creates a new album with the given ID.
55          *
56          * @param id
57          *            The ID of the album
58          */
59         public Album(String id) {
60                 this.id = id;
61         }
62
63         //
64         // ACCESSORS
65         //
66
67         /**
68          * Returns the ID of this album.
69          *
70          * @return The ID of this album
71          */
72         public String getId() {
73                 return id;
74         }
75
76         /**
77          * Returns the nested albums.
78          *
79          * @return The nested albums
80          */
81         public List<Album> getNestedAlbums() {
82                 return new ArrayList<Album>(albums);
83         }
84
85         /**
86          * Returns the images in this album.
87          *
88          * @return The images in this album
89          */
90         public List<Image> getImages() {
91                 return new ArrayList<Image>(images);
92         }
93
94         /**
95          * Returns the name of this album.
96          *
97          * @return The name of this album
98          */
99         public String getName() {
100                 return name;
101         }
102
103         /**
104          * Sets the name of this album.
105          *
106          * @param name
107          *            The name of this album
108          * @return This album
109          */
110         public Album setName(String name) {
111                 this.name = name;
112                 return this;
113         }
114
115         /**
116          * Returns the description of this album.
117          *
118          * @return The description of this album
119          */
120         public String getDescription() {
121                 return description;
122         }
123
124         /**
125          * Sets the description of this album.
126          *
127          * @param description
128          *            The description of this album
129          * @return This album
130          */
131         public Album setDescription(String description) {
132                 this.description = description;
133                 return this;
134         }
135
136         //
137         // OBJECT METHODS
138         //
139
140         /**
141          * {@inheritDoc}
142          */
143         @Override
144         public boolean equals(Object object) {
145                 if (!(object instanceof Album)) {
146                         return false;
147                 }
148                 Album album = (Album) object;
149                 return id.equals(album.id);
150         }
151
152 }