summaryrefslogtreecommitdiff
path: root/micropeak/MicroUSB.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2018-10-02 12:49:12 -0700
committerKeith Packard <keithp@keithp.com>2018-10-02 13:00:32 -0700
commit523e51d2cd2dfc5c0c4ca5a893b005916c46d46a (patch)
treee0ca2e2c43281497c2108b49e2196eee0c4fbd7f /micropeak/MicroUSB.java
parent8dd942b59edbe6909128b88bfbb8d1e15c3857c6 (diff)
micropeak: Add MicroUSB 'equals' method
This lets the code which polls for devices work with MicroUSB devices too. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'micropeak/MicroUSB.java')
-rw-r--r--micropeak/MicroUSB.java19
1 files changed, 19 insertions, 0 deletions
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<MicroUSB> list() {
if (!load_library())
return null;