2 * DemosceneMusic - AbstractGroup.java - Copyright © 2012 David Roden
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.
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.
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/>.
18 package net.pterodactylus.demoscenemusic.data;
20 import java.util.Collection;
21 import java.util.Comparator;
24 * Default implementation of a group data container.
26 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
28 public class DefaultGroup extends DefaultBase implements Group {
30 /** Comparator that sorts groups by name. */
31 public static final Comparator<Group> NAME_COMPARATOR = new Comparator<Group>() {
34 public int compare(Group leftGroup, Group rightGroup) {
35 return leftGroup.getName().compareToIgnoreCase(rightGroup.getName());
41 * Creates a new group data container.
46 public DefaultGroup(String id) {
58 public String getName() {
59 return getValue("name", String.class).get();
66 public Group setName(String name) {
67 getValue("name", String.class).set(name);
75 public String getShortName() {
76 return getValue("shortName", String.class).get();
83 public Group setShortName(String shortName) {
84 getValue("shortName", String.class).set(shortName);
92 @SuppressWarnings("unchecked")
93 public Collection<Artist> getArtists() {
94 return getValue("artists", Collection.class).get();
101 public Group setArtists(Collection<Artist> artists) {
102 getValue("artists", Collection.class).set(artists);
114 public int hashCode() {
115 return getId().hashCode();
122 public boolean equals(Object object) {
123 if (!(object instanceof Group)) {
126 return ((Group) object).getId().equals(getId());