Override hashCode(), equals(), and toString().
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Mar 2013 19:04:06 +0000 (20:04 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Mar 2013 19:04:06 +0000 (20:04 +0100)
src/main/java/net/pterodactylus/sonitus/data/Format.java

index a06889f..84a070d 100644 (file)
@@ -81,4 +81,27 @@ public class Format {
                return encoding;
        }
 
+       //
+       // OBJECT METHODS
+       //
+
+       @Override
+       public int hashCode() {
+               return (channels << 16) ^ frequency ^ encoding.hashCode();
+       }
+
+       @Override
+       public boolean equals(Object object) {
+               if ((object == null) || (getClass() != object.getClass())) {
+                       return false;
+               }
+               Format format = (Format) object;
+               return (format.channels == channels) && (format.frequency == frequency) && format.encoding.equals(encoding());
+       }
+
+       @Override
+       public String toString() {
+               return String.format("%d Channels, %d Hz, %s", channels, frequency, encoding);
+       }
+
 }