From 9eee0f4f619731e5f8b79396d2476090d328be6b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 30 Jul 2012 14:26:57 +0200 Subject: [PATCH] Override Object.hashCode() and Object.equals(). --- .../demoscenemusic/data/DefaultArtist.java | 23 ++++++++++++++++++++++ .../demoscenemusic/data/DefaultGroup.java | 23 ++++++++++++++++++++++ .../demoscenemusic/data/DefaultParty.java | 23 ++++++++++++++++++++++ .../demoscenemusic/data/DefaultStyle.java | 23 ++++++++++++++++++++++ .../demoscenemusic/data/DefaultTrack.java | 23 ++++++++++++++++++++++ .../data/DefaultTrackDerivative.java | 23 ++++++++++++++++++++++ .../demoscenemusic/data/DefaultUser.java | 23 ++++++++++++++++++++++ 7 files changed, 161 insertions(+) diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultArtist.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultArtist.java index 4d359aa..151aeca 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultArtist.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultArtist.java @@ -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()); + } + } diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultGroup.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultGroup.java index 437fadb..16c1c76 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultGroup.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultGroup.java @@ -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()); + } + } diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultParty.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultParty.java index f621d4d..3e0f296 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultParty.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultParty.java @@ -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()); + } + } diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultStyle.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultStyle.java index 1b6ae3c..3256f64 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultStyle.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultStyle.java @@ -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()); + } + } diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrack.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrack.java index ffeb003..0c01a2c 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrack.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrack.java @@ -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()); + } + } diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrackDerivative.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrackDerivative.java index dde5a3e..28fe97f 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrackDerivative.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrackDerivative.java @@ -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()); + } + } diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultUser.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultUser.java index fb2836c..824d54e 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultUser.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultUser.java @@ -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()); + } + } -- 2.7.4