Override Object.hashCode() and Object.equals().
[demoscenemusic.git] / src / main / java / net / pterodactylus / demoscenemusic / data / DefaultTrack.java
index db358f8..0c01a2c 100644 (file)
@@ -19,49 +19,192 @@ package net.pterodactylus.demoscenemusic.data;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 /**
- * TODO
+ * Default implementation of a track data container.
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
 public class DefaultTrack extends DefaultBase implements Track {
 
+       /**
+        * Creates a new track data container.
+        *
+        * @param id
+        *            The ID of the track
+        */
        public DefaultTrack(String id) {
                super(id);
        }
 
+       //
+       // TRACK METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public String getName() {
+               return getValue("name", String.class).get();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public Track setName(String name) {
+               getValue("name", String.class).set(name);
+               return this;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       @SuppressWarnings("unchecked")
+       public List<Artist> getArtists() {
+               return getValue("artists", List.class).get();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public Track setArtists(List<Artist> artists) {
+               getValue("artists", List.class).set(artists);
+               return this;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       @SuppressWarnings("unchecked")
+       public Collection<Style> getStyles() {
+               return getValue("styles", Collection.class).get();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public Track setStyles(Collection<? extends Style> styles) {
+               getValue("styles", Collection.class).set(styles);
+               return this;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
        @Override
-       public String name() {
-               return value("name", String.class).get();
+       public String getRemix() {
+               return getValue("remix", String.class).get();
        }
 
+       /**
+        * {@inheritDoc}
+        */
        @Override
-       public Track name(String name) {
-               value("name", String.class).set(name);
+       public Track setRemix(String remix) {
+               getValue("remix", String.class).set(remix);
                return this;
        }
 
+       /**
+        * {@inheritDoc}
+        */
        @Override
-       public List<Artist> artists() {
-               return value("artists", List.class).get();
+       @SuppressWarnings("unchecked")
+       public List<Artist> getRemixArtists() {
+               return getValue("remixArtists", List.class).get();
        }
 
+       /**
+        * {@inheritDoc}
+        */
        @Override
-       public Track artists(List<Artist> artists) {
-               value("artists", List.class).set(artists);
+       public Track setRemixArtists(List<Artist> remixArtists) {
+               getValue("remixArtists", List.class).set(remixArtists);
                return this;
        }
 
+       /**
+        * {@inheritDoc}
+        */
        @Override
-       public Collection<Style> styles() {
-               return value("styles", Collection.class).get();
+       @SuppressWarnings("unchecked")
+       public Collection<TrackDerivative> getDerivatives() {
+               return getValue("derivatives", Collection.class).get();
        }
 
+       /**
+        * {@inheritDoc}
+        */
        @Override
-       public Track styles(Collection<? extends Style> styles) {
-               value("styles", Collection.class).set(styles);
+       public Track setDerivatives(Collection<TrackDerivative> derivatives) {
+               getValue("derivatives", Collection.class).set(derivatives);
                return this;
        }
 
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       @SuppressWarnings("unchecked")
+       public Map<Relationship, Collection<Track>> getRelatedTracks() {
+               return getValue("relatedTracks", Map.class).get();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public Track setRelatedTracks(Map<Relationship, Collection<Track>> relatedTracks) {
+               getValue("relatedTracks", Map.class).set(relatedTracks);
+               return this;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       @SuppressWarnings("unchecked")
+       public Collection<Party> getParties() {
+               return getValue("parties", Collection.class).get();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public Track setParties(Collection<Party> parties) {
+               getValue("parties", Collection.class).set(parties);
+               return this;
+       }
+
+       //
+       // OBJECT METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public int hashCode() {
+               return getId().hashCode();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof Track)) {
+                       return false;
+               }
+               return ((Track) object).getId().equals(getId());
+       }
+
 }