Add owner Sone 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         /** The Sone this album belongs to. */
35         private final Sone sone;
36
37         /** Nested albums. */
38         private final List<Album> albums = new ArrayList<Album>();
39
40         /** The images in this album. */
41         private final List<Image> images = new ArrayList<Image>();
42
43         /** The name of this album. */
44         private String name;
45
46         /** The description of this album. */
47         private String description;
48
49         /**
50          * Creates a new album with a random ID.
51          *
52          * @param sone
53          *            The Sone this album belongs to
54          */
55         public Album(Sone sone) {
56                 this(UUID.randomUUID().toString(), sone);
57         }
58
59         /**
60          * Creates a new album with the given ID.
61          *
62          * @param id
63          *            The ID of the album
64          * @param sone
65          *            The Sone this album belongs to
66          */
67         public Album(String id, Sone sone) {
68                 this.id = id;
69                 this.sone = sone;
70         }
71
72         //
73         // ACCESSORS
74         //
75
76         /**
77          * Returns the ID of this album.
78          *
79          * @return The ID of this album
80          */
81         public String getId() {
82                 return id;
83         }
84
85         /**
86          * Returns the Sone this album belongs to.
87          *
88          * @return The Sone this album belongs to
89          */
90         public Sone getSone() {
91                 return sone;
92         }
93
94         /**
95          * Returns the nested albums.
96          *
97          * @return The nested albums
98          */
99         public List<Album> getNestedAlbums() {
100                 return new ArrayList<Album>(albums);
101         }
102
103         /**
104          * Returns the images in this album.
105          *
106          * @return The images in this album
107          */
108         public List<Image> getImages() {
109                 return new ArrayList<Image>(images);
110         }
111
112         /**
113          * Returns the name of this album.
114          *
115          * @return The name of this album
116          */
117         public String getName() {
118                 return name;
119         }
120
121         /**
122          * Sets the name of this album.
123          *
124          * @param name
125          *            The name of this album
126          * @return This album
127          */
128         public Album setName(String name) {
129                 this.name = name;
130                 return this;
131         }
132
133         /**
134          * Returns the description of this album.
135          *
136          * @return The description of this album
137          */
138         public String getDescription() {
139                 return description;
140         }
141
142         /**
143          * Sets the description of this album.
144          *
145          * @param description
146          *            The description of this album
147          * @return This album
148          */
149         public Album setDescription(String description) {
150                 this.description = description;
151                 return this;
152         }
153
154         //
155         // OBJECT METHODS
156         //
157
158         /**
159          * {@inheritDoc}
160          */
161         @Override
162         public boolean equals(Object object) {
163                 if (!(object instanceof Album)) {
164                         return false;
165                 }
166                 Album album = (Album) object;
167                 return sone.equals(album.sone) && id.equals(album.id);
168         }
169
170 }