From 523e51d2cd2dfc5c0c4ca5a893b005916c46d46a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 2 Oct 2018 12:49:12 -0700 Subject: [PATCH] micropeak: Add MicroUSB 'equals' method This lets the code which polls for devices work with MicroUSB devices too. Signed-off-by: Keith Packard --- micropeak/MicroUSB.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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; -- 2.30.2