From: Keith Packard Date: Tue, 2 Oct 2018 19:49:12 +0000 (-0700) Subject: micropeak: Add MicroUSB 'equals' method X-Git-Tag: 1.8.7~3^2~47 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=523e51d2cd2dfc5c0c4ca5a893b005916c46d46a micropeak: Add MicroUSB 'equals' method This lets the code which polls for devices work with MicroUSB devices too. Signed-off-by: Keith Packard --- diff --git a/micropeak/MicroUSB.java b/micropeak/MicroUSB.java index dcc4b602..092c3d44 100644 --- a/micropeak/MicroUSB.java +++ b/micropeak/MicroUSB.java @@ -97,6 +97,25 @@ public class MicroUSB extends altos_device implements AltosDevice { return isFTDI() || isMicro(); } + public int hashCode() { + return getVendor() ^ getProduct() ^ getSerial() ^ getPath().hashCode(); + } + + public boolean equals(Object o) { + if (o == null) + return false; + + if (!(o instanceof MicroUSB)) + return false; + + MicroUSB other = (MicroUSB) o; + + return getVendor() == other.getVendor() && + getProduct() == other.getProduct() && + getSerial() == other.getSerial() && + getPath().equals(other.getPath()); + } + static java.util.List list() { if (!load_library()) return null;