Override Object.hashCode() and Object.equals().
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 30 Jul 2012 12:26:57 +0000 (14:26 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 30 Jul 2012 12:26:57 +0000 (14:26 +0200)
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultArtist.java
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultGroup.java
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultParty.java
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultStyle.java
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrack.java
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrackDerivative.java
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultUser.java

index 4d359aa..151aeca 100644 (file)
@@ -103,4 +103,27 @@ public class DefaultArtist extends DefaultBase implements Artist {
                return this;
        }
 
+       //
+       // OBJECT METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public int hashCode() {
+               return getId().hashCode();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof Artist)) {
+                       return false;
+               }
+               return ((Artist) object).getId().equals(getId());
+       }
+
 }
index 437fadb..16c1c76 100644 (file)
@@ -92,4 +92,27 @@ public class DefaultGroup extends DefaultBase implements Group {
                return this;
        }
 
+       //
+       // OBJECT METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public int hashCode() {
+               return getId().hashCode();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof Group)) {
+                       return false;
+               }
+               return ((Group) object).getId().equals(getId());
+       }
+
 }
index f621d4d..3e0f296 100644 (file)
@@ -95,4 +95,27 @@ public class DefaultParty extends DefaultBase implements Party {
                return this;
        }
 
+       //
+       // OBJECT METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public int hashCode() {
+               return getId().hashCode();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof Party)) {
+                       return false;
+               }
+               return ((Party) object).getId().equals(getId());
+       }
+
 }
index 1b6ae3c..3256f64 100644 (file)
@@ -55,4 +55,27 @@ public class DefaultStyle extends DefaultBase implements Style {
                return this;
        }
 
+       //
+       // OBJECT METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public int hashCode() {
+               return getId().hashCode();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof Style)) {
+                       return false;
+               }
+               return ((Style) object).getId().equals(getId());
+       }
+
 }
index ffeb003..0c01a2c 100644 (file)
@@ -184,4 +184,27 @@ public class DefaultTrack extends DefaultBase implements Track {
                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());
+       }
+
 }
index dde5a3e..28fe97f 100644 (file)
@@ -34,4 +34,27 @@ public class DefaultTrackDerivative extends DefaultBase implements TrackDerivati
                super(id);
        }
 
+       //
+       // OBJECT METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public int hashCode() {
+               return getId().hashCode();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof TrackDerivative)) {
+                       return false;
+               }
+               return ((TrackDerivative) object).getId().equals(getId());
+       }
+
 }
index fb2836c..824d54e 100644 (file)
@@ -127,4 +127,27 @@ public class DefaultUser extends DefaultBase implements User {
                return this;
        }
 
+       //
+       // OBJECT METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public int hashCode() {
+               return getId().hashCode();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof User)) {
+                       return false;
+               }
+               return ((User) object).getId().equals(getId());
+       }
+
 }