Override hashCode() and equals().
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 8 Nov 2013 17:46:18 +0000 (18:46 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:55 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/text/SonePart.java

index 7c0c34f..602ff05 100644 (file)
 
 package net.pterodactylus.sone.text;
 
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.hashCode;
+
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.template.SoneAccessor;
 
+import com.google.common.base.Objects;
+
 /**
  * {@link Part} implementation that stores a reference to a {@link Sone}.
  *
@@ -62,4 +67,18 @@ public class SonePart implements Part {
                return SoneAccessor.getNiceName(sone);
        }
 
+       @Override
+       public int hashCode() {
+               return Objects.hashCode(sone);
+       }
+
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof SonePart)) {
+                       return false;
+               }
+               SonePart sonePart = (SonePart) object;
+               return equal(getSone(), sonePart.getSone());
+       }
+
 }