package net.pterodactylus.demoscenemusic.data;
import java.util.Collection;
+import java.util.Comparator;
/**
* Default implementation of a group data container.
*/
public class DefaultGroup extends DefaultBase implements Group {
+ /** Comparator that sorts groups by name. */
+ public static final Comparator<Group> NAME_COMPARATOR = new Comparator<Group>() {
+
+ @Override
+ public int compare(Group leftGroup, Group rightGroup) {
+ return leftGroup.getName().compareToIgnoreCase(rightGroup.getName());
+ }
+
+ };
+
/**
* Creates a new group data container.
*
* {@inheritDoc}
*/
@Override
- public String getUrl() {
- return getValue("url", String.class).get();
+ @SuppressWarnings("unchecked")
+ public Collection<Artist> getArtists() {
+ return getValue("artists", Collection.class).get();
}
/**
* {@inheritDoc}
*/
@Override
- public Group setUrl(String url) {
- getValue("url", String.class).set(url);
+ public Group setArtists(Collection<Artist> artists) {
+ getValue("artists", Collection.class).set(artists);
return this;
}
+ //
+ // OBJECT METHODS
+ //
+
/**
* {@inheritDoc}
*/
@Override
- @SuppressWarnings("unchecked")
- public Collection<Artist> getArtists() {
- return getValue("artists", Collection.class).get();
+ public int hashCode() {
+ return getId().hashCode();
}
/**
* {@inheritDoc}
*/
@Override
- public Group setArtists(Collection<Artist> artists) {
- getValue("artists", Collection.class).set(artists);
- return this;
+ public boolean equals(Object object) {
+ if (!(object instanceof Group)) {
+ return false;
+ }
+ return ((Group) object).getId().equals(getId());
}
}