From abbc1761cc1ff6eb1b4a68b73eaa1064233b4d6b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 14 Mar 2013 20:04:06 +0100 Subject: [PATCH] Override hashCode(), equals(), and toString(). --- .../net/pterodactylus/sonitus/data/Format.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/net/pterodactylus/sonitus/data/Format.java b/src/main/java/net/pterodactylus/sonitus/data/Format.java index a06889f..84a070d 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/Format.java +++ b/src/main/java/net/pterodactylus/sonitus/data/Format.java @@ -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); + } + } -- 2.7.4