diff options
author | Keith Packard <keithp@keithp.com> | 2018-08-22 00:53:46 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2018-08-22 01:01:46 -0700 |
commit | 91bb344a74a413f7dcee379c4d760c34599749bc (patch) | |
tree | 33c25e8242ecaebccb3672579c92c80fc66c6d6b /altosuilib/AltosUSBDevice.java | |
parent | 2f61ef9a5046c39f4eeaaf741031bb6a9607b8a6 (diff) |
altosuilib: Add 'equals' method to AltosDevice
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosuilib/AltosUSBDevice.java')
-rw-r--r-- | altosuilib/AltosUSBDevice.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/altosuilib/AltosUSBDevice.java b/altosuilib/AltosUSBDevice.java index f7aae38a..16a0e770 100644 --- a/altosuilib/AltosUSBDevice.java +++ b/altosuilib/AltosUSBDevice.java @@ -94,6 +94,23 @@ public class AltosUSBDevice extends altos_device implements AltosDevice { return false; } + public int hashCode() { + return getVendor() ^ getProduct() ^ getSerial(); + } + + public boolean equals(Object o) { + if (o == null) + return false; + + if (!(o instanceof AltosUSBDevice)) + return false; + AltosUSBDevice other = (AltosUSBDevice) o; + + return getVendor() == other.getVendor() && + getProduct() == other.getProduct() && + getSerial() == other.getSerial(); + } + static public java.util.List<AltosDevice> list(int product) { if (!AltosUILib.load_library()) return null; |